diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 4c43190e40df5e..78155eb5926d74 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -1184,21 +1184,6 @@ config KERNEL_XDP_SOCKETS XDP sockets allows a channel between XDP programs and userspace applications. -config KERNEL_WIRELESS_EXT - def_bool n - -config KERNEL_WEXT_CORE - def_bool KERNEL_WIRELESS_EXT - -config KERNEL_WEXT_PRIV - def_bool KERNEL_WIRELESS_EXT - -config KERNEL_WEXT_PROC - def_bool KERNEL_WIRELESS_EXT - -config KERNEL_WEXT_SPY - def_bool KERNEL_WIRELESS_EXT - config KERNEL_PAGE_POOL def_bool n diff --git a/include/image-commands.mk b/include/image-commands.mk index 41a5e1198a95a0..79a64f4bc13997 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -152,6 +152,20 @@ define Build/append-ubi $(call Build/check-size,$(UBI_NAND_SIZE_LIMIT))) endef +define Build/ubinize-image + sh $(TOPDIR)/scripts/ubinize-image.sh \ + $(if $(UBOOTENV_IN_UBI),--uboot-env) \ + $(foreach part,$(UBINIZE_PARTS),--part $(part)) \ + --part $(word 1,$(1))="$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(word 2,$(1))" \ + $@.tmp \ + -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \ + $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \ + $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \ + $(UBINIZE_OPTS) + cat $@.tmp >> $@ + rm $@.tmp +endef + define Build/ubinize-kernel cp $@ $@.tmp sh $(TOPDIR)/scripts/ubinize-image.sh \ diff --git a/include/image.mk b/include/image.mk index f5ab1d7953c5ae..4b6acbe1aad6ac 100644 --- a/include/image.mk +++ b/include/image.mk @@ -582,7 +582,7 @@ define Device/Build/dtb $(KDIR)/image-$(1).dtb: FORCE $(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dts,$$@) - image_prepare: $(KDIR)/image-$(1).dtb + compile-dtb: $(KDIR)/image-$(1).dtb endif endef @@ -593,7 +593,7 @@ define Device/Build/dtbo $(KDIR)/image-$(1).dtbo: FORCE $(call Image/BuildDTBO,$(strip $(2))/$(strip $(3)).dtso,$$@) - image_prepare: $(KDIR)/image-$(1).dtbo + compile-dtb: $(KDIR)/image-$(1).dtbo endif endef @@ -841,18 +841,20 @@ define BuildImage download: prepare: compile: + compile-dtb: clean: image_prepare: ifeq ($(IB),) - .PHONY: download prepare compile clean image_prepare kernel_prepare install install-images + .PHONY: download prepare compile compile-dtb clean image_prepare kernel_prepare install install-images compile: $(call Build/Compile) clean: $(call Build/Clean) - image_prepare: compile + compile-dtb: + image_prepare: compile compile-dtb mkdir -p $(BIN_DIR) $(KDIR)/tmp rm -rf $(BUILD_DIR)/json_info_files $(call Image/Prepare) diff --git a/include/kernel-5.15 b/include/kernel-5.15 index 5cc07434b2a6cd..d93ae194b8aa1c 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .147 -LINUX_KERNEL_HASH-5.15.147 = 56c1e65625d201db431efda7a3816e7b424071e7cb0245b2ba594d15b1fdfcd4 +LINUX_VERSION-5.15 = .148 +LINUX_KERNEL_HASH-5.15.148 = c48575c97fd9f4767cbe50a13b1b2b40ee42830aba3182fabd35a03259a6e5d8 diff --git a/include/kernel-6.1 b/include/kernel-6.1 index 87c6bf50977fe0..6c05ca0236eed2 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .74 -LINUX_KERNEL_HASH-6.1.74 = b7fbd1d79faed2ce3570ef79dc1223e4e19c868b86326b14a435db56ebbb2022 +LINUX_VERSION-6.1 = .79 +LINUX_KERNEL_HASH-6.1.79 = faa49ca22fb55ed4d5ca2a55e07dd10e4e171cfc3b92568a631453cd2068b39b diff --git a/include/kernel-build.mk b/include/kernel-build.mk index b9513ec41435fb..c42dae0049ba4f 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -156,6 +156,10 @@ define BuildKernel compile: $(LINUX_DIR)/.modules $(MAKE) -C image compile TARGET_BUILD= + dtb: $(STAMP_CONFIGURED) + $(_SINGLE)$(KERNEL_MAKE) scripts_dtc + $(MAKE) -C image compile-dtb TARGET_BUILD= + oldconfig menuconfig nconfig xconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE rm -f $(LINUX_DIR)/.config.prev rm -f $(STAMP_CONFIGURED) diff --git a/include/package-defaults.mk b/include/package-defaults.mk index 30b112c7d8cc9c..392aad0d5db8e0 100644 --- a/include/package-defaults.mk +++ b/include/package-defaults.mk @@ -20,7 +20,7 @@ define Package/Default PROVIDES:= EXTRA_DEPENDS:= MAINTAINER:=$(PKG_MAINTAINER) - SOURCE:=$(patsubst $(TOPDIR)/%,%,$(CURDIR)) + SOURCE:=$(patsubst $(TOPDIR)/%,%,$(patsubst $(TOPDIR)/package/%,feeds/base/%,$(CURDIR))) ifneq ($(PKG_VERSION),) ifneq ($(PKG_RELEASE),) VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) diff --git a/include/rootfs.mk b/include/rootfs.mk index f2ed648d2f3eb5..2128aefc2abda8 100644 --- a/include/rootfs.mk +++ b/include/rootfs.mk @@ -87,6 +87,11 @@ define prepare_rootfs fi; \ done || true \ ) + awk -i inplace \ + '/^Status:/ { \ + if ($$3 == "user") { $$3 = "ok" } \ + else { sub(/,\|\,/, "", $$3) } \ + }1' $(1)/usr/lib/opkg/status $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status) @-find $(1) -name CVS -o -name .svn -o -name .git -o -name '.#*' | $(XARGS) rm -rf rm -rf \ diff --git a/include/subdir.mk b/include/subdir.mk index 95009f814e29d4..b4edbf8b96c784 100644 --- a/include/subdir.mk +++ b/include/subdir.mk @@ -5,6 +5,9 @@ ifeq ($(MAKECMDGOALS),prereq) SUBTARGETS:=prereq PREREQ_ONLY:=1 +# For target/linux related target add dtb to selectively compile dtbs +else ifneq ($(filter target/linux/%,$(MAKECMDGOALS)),) + SUBTARGETS:=$(DEFAULT_SUBDIR_TARGETS) dtb else SUBTARGETS:=$(DEFAULT_SUBDIR_TARGETS) endif diff --git a/include/toplevel.mk b/include/toplevel.mk index f2dfde60cff929..4ec99b30de30fd 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -77,7 +77,8 @@ _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p)) prepare-tmpinfo: FORCE @+$(MAKE) -r -s $(STAGING_DIR_HOST)/.prereq-build $(PREP_MK) - mkdir -p tmp/info + mkdir -p tmp/info feeds + [ -e $(TOPDIR)/feeds/base ] || ln -sf $(TOPDIR)/package $(TOPDIR)/feeds/base $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPTH=5 SCAN_EXTRA="" $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=3 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1" for type in package target; do \ diff --git a/include/u-boot.mk b/include/u-boot.mk index 06867a70e426b6..454880989b5ec0 100644 --- a/include/u-boot.mk +++ b/include/u-boot.mk @@ -69,6 +69,7 @@ endef TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET)) UBOOT_MAKE_FLAGS = \ + PATH=$(STAGING_DIR_HOST)/bin:$(PATH) \ HOSTCC="$(HOSTCC)" \ HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \ HOSTLDFLAGS="$(HOST_LDFLAGS)" \ diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led index 08a1e6df3bbaf6..ea2688cab29efa 100755 --- a/package/base-files/files/etc/init.d/led +++ b/package/base-files/files/etc/init.d/led @@ -3,6 +3,39 @@ START=96 +led_color_set() { + local cfg="$1" + local sysfs="$2" + + local max_b + local colors + local color + local multi_intensity + local value + local write + + [ -e /sys/class/leds/${sysfs}/multi_intensity ] || return + [ -e /sys/class/leds/${sysfs}/multi_index ] || return + + max_b="$(cat /sys/class/leds/${sysfs}/max_brightness)" + colors="$(cat /sys/class/leds/${sysfs}/multi_index | tr " " "\n")" + multi_intensity="" + for color in $colors; do + config_get value $1 "color_${color}" "0" + [ "$value" -gt 0 ] && write=1 + [ "$value" -gt "$max_b" ] && value="$max_b" + multi_intensity="${multi_intensity}${value} " + done + + # Check if any color is configured + [ "$write" = 1 ] || return + # Remove last whitespace + multi_intensity="${multi_intensity:0:-1}" + + echo "setting '${name}' led color to '${multi_intensity}'" + echo "${multi_intensity}" > /sys/class/leds/${sysfs}/multi_intensity +} + load_led() { local name local sysfs @@ -49,21 +82,29 @@ load_led() { [ -e /sys/class/leds/${sysfs}/brightness ] && { echo "setting up led ${name}" - printf "%s %s %d\n" \ + printf "%s %s %d" \ "$sysfs" \ "$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \ "$(cat /sys/class/leds/${sysfs}/brightness)" \ >> /var/run/led.state + # Save default color if supported + [ -e /sys/class/leds/${sysfs}/multi_intensity ] && { + printf " %s" \ + "$(sed 's/\ /:/g' /sys/class/leds/${sysfs}/multi_intensity)" \ + >> /var/run/led.state + } + printf "\n" >> /var/run/led.state [ "$default" = 0 ] && echo 0 >/sys/class/leds/${sysfs}/brightness - echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null - ret="$?" - [ $default = 1 ] && cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness + led_color_set "$1" "$sysfs" + + echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null + ret="$?" [ $ret = 0 ] || { echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module" return 1 @@ -128,13 +169,17 @@ load_led() { start() { [ -e /sys/class/leds/ ] && { [ -s /var/run/led.state ] && { - local led trigger brightness - while read led trigger brightness; do + local led trigger brightness color + while read led trigger brightness color; do [ -e "/sys/class/leds/$led/trigger" ] && \ echo "$trigger" > "/sys/class/leds/$led/trigger" [ -e "/sys/class/leds/$led/brightness" ] && \ echo "$brightness" > "/sys/class/leds/$led/brightness" + + [ -e "/sys/class/leds/$led/multi_intensity" ] && \ + echo "$color" | sed 's/:/\ /g' > \ + "/sys/class/leds/$led/multi_intensity" done < /var/run/led.state rm /var/run/led.state } diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index a75bd116525b7e..b89cc8e9e309ab 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -654,6 +654,17 @@ ucidef_set_ntpserver() { json_select .. } +ucidef_set_poe() { + json_select_object poe + json_add_string "budget" "$1" + json_select_array ports + for port in $2; do + json_add_string "" "$port" + done + json_select .. + json_select .. +} + ucidef_add_wlan() { local path="$1"; shift diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index af1182cb16a383..ef8d01e16896f3 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -165,6 +165,23 @@ part_magic_fat() { [ "$magic" = "FAT" ] || [ "$magic_fat32" = "FAT32" ] } +fitblk_get_bootdev() { + [ -e /sys/firmware/devicetree/base/chosen/rootdisk ] || return + + local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)" + local handle bootdev + for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat $handle)" ]; then + bootdev="${handle%/of_node/phandle}" + bootdev="${bootdev%/device}" + bootdev="${bootdev#/sys/class/block/}" + echo "$bootdev" + break + fi + done +} + export_bootdevice() { local cmdline uuid blockdev uevent line class local MAJOR MINOR DEVNAME DEVTYPE @@ -196,6 +213,7 @@ export_bootdevice() { done ;; /dev/*) + [ "$rootpart" = "/dev/fit0" ] && rootpart="$(fitblk_get_bootdev)" uevent="/sys/class/block/${rootpart##*/}/../uevent" ;; 0x[a-f0-9][a-f0-9][a-f0-9] | 0x[a-f0-9][a-f0-9][a-f0-9][a-f0-9] | \ diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index d910bf17915982..0a6fd8432d4623 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -111,7 +111,7 @@ nand_remove_ubiblock() { local ubiblk="ubiblock${ubivol:3}" if [ -e "/dev/$ubiblk" ]; then - umount "/dev/$ubiblk" && echo "unmounted /dev/$ubiblk" || : + umount "/dev/$ubiblk" 2>/dev/null && echo "unmounted /dev/$ubiblk" || : if ! ubiblock -r "/dev/$ubivol"; then echo "cannot remove $ubiblk" return 1 diff --git a/package/base-files/files/lib/upgrade/tar.sh b/package/base-files/files/lib/upgrade/tar.sh new file mode 100644 index 00000000000000..a9d1d559e6f7dd --- /dev/null +++ b/package/base-files/files/lib/upgrade/tar.sh @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +# Example usage: +# +# { +# tar_print_member "date.txt" "It's $(date +"%Y")" +# tar_print_trailer +# } > test.tar + +__tar_print_padding() { + dd if=/dev/zero bs=1 count=$1 2>/dev/null +} + +tar_print_member() { + local name="$1" + local content="$2" + local mtime="${3:-$(date +%s)}" + local mode=644 + local uid=0 + local gid=0 + local size=${#content} + local type=0 + local link="" + local username="root" + local groupname="root" + + # 100 byte of padding bytes, using 0x01 since the shell does not tolerate null bytes in strings + local pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1' + + # validate name (strip leading slash if present) + name=${name#/} + + # truncate string header values to their maximum length + name=${name:0:100} + link=${link:0:100} + username=${username:0:32} + groupname=${groupname:0:32} + + # construct header part before checksum field + local header1="${name}${pad:0:$((100 - ${#name}))}" + header1="${header1}$(printf '%07d\1' $mode)" + header1="${header1}$(printf '%07o\1' $uid)" + header1="${header1}$(printf '%07o\1' $gid)" + header1="${header1}$(printf '%011o\1' $size)" + header1="${header1}$(printf '%011o\1' $mtime)" + + # construct header part after checksum field + local header2="$(printf '%d' $type)" + header2="${header2}${link}${pad:0:$((100 - ${#link}))}" + header2="${header2}ustar ${pad:0:1}" + header2="${header2}${username}${pad:0:$((32 - ${#username}))}" + header2="${header2}${groupname}${pad:0:$((32 - ${#groupname}))}" + + # calculate checksum over header fields + local checksum=0 + for byte in $(printf '%s%8s%s' "$header1" "" "$header2" | tr '\1' '\0' | hexdump -ve '1/1 "%u "'); do + checksum=$((checksum + byte)) + done + + # print member header, padded to 512 byte + printf '%s%06o\0 %s' "$header1" $checksum "$header2" | tr '\1' '\0' + __tar_print_padding 183 + + # print content data, padded to multiple of 512 byte + printf "%s" "$content" + __tar_print_padding $((512 - (size % 512))) +} + +tar_print_trailer() { + __tar_print_padding 1024 +} diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 93150913024fb7..78ec455067910a 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -4,27 +4,35 @@ . /lib/functions/system.sh . /usr/share/libubox/jshn.sh -# initialize defaults +# File-local constants +CONF_TAR=/tmp/sysupgrade.tgz +ETCBACKUP_DIR=/etc/backup +INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt +COMMAND=/lib/upgrade/do_stage2 + +# File-local globals +SAVE_OVERLAY=0 +SAVE_OVERLAY_PATH= +SAVE_PARTITIONS=1 +SAVE_INSTALLED_PKGS=0 +SKIP_UNCHANGED=0 +CONF_IMAGE= +CONF_BACKUP_LIST=0 +CONF_BACKUP= +CONF_RESTORE= +NEED_IMAGE= +HELP=0 +TEST=0 + +# Globals accessed in other files export MTD_ARGS="" export MTD_CONFIG_ARGS="" export INTERACTIVE=0 export VERBOSE=1 export SAVE_CONFIG=1 -export SAVE_OVERLAY=0 -export SAVE_OVERLAY_PATH= -export SAVE_PARTITIONS=1 -export SAVE_INSTALLED_PKGS=0 -export SKIP_UNCHANGED=0 -export CONF_IMAGE= -export CONF_BACKUP_LIST=0 -export CONF_BACKUP= -export CONF_RESTORE= export IGNORE_MINOR_COMPAT=0 -export NEED_IMAGE= -export HELP=0 export FORCE=0 -export TEST=0 -export UMOUNT_ETCBACKUP_DIR=0 +export CONFFILES=/tmp/sysupgrade.conffiles # parse options while [ -n "$1" ]; do @@ -33,18 +41,18 @@ while [ -n "$1" ]; do -v) export VERBOSE="$(($VERBOSE + 1))";; -q) export VERBOSE="$(($VERBOSE - 1))";; -n) export SAVE_CONFIG=0;; - -c) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;; - -o) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;; - -p) export SAVE_PARTITIONS=0;; - -k) export SAVE_INSTALLED_PKGS=1;; - -u) export SKIP_UNCHANGED=1;; - -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;; - -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;; - -l|--list-backup) export CONF_BACKUP_LIST=1;; - -f) export CONF_IMAGE="$2"; shift;; + -c) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;; + -o) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;; + -p) SAVE_PARTITIONS=0;; + -k) SAVE_INSTALLED_PKGS=1;; + -u) SKIP_UNCHANGED=1;; + -b|--create-backup) CONF_BACKUP="$2" NEED_IMAGE=1; shift;; + -r|--restore-backup) CONF_RESTORE="$2" NEED_IMAGE=1; shift;; + -l|--list-backup) CONF_BACKUP_LIST=1;; + -f) CONF_IMAGE="$2"; shift;; -F|--force) export FORCE=1;; - -T|--test) export TEST=1;; - -h|--help) export HELP=1; break;; + -T|--test) TEST=1;; + -h|--help) HELP=1; break;; --ignore-minor-compat-version) export IGNORE_MINOR_COMPAT=1;; -*) echo "Invalid option: $1" >&2 @@ -55,14 +63,7 @@ while [ -n "$1" ]; do shift; done -export CONFFILES=/tmp/sysupgrade.conffiles -export CONF_TAR=/tmp/sysupgrade.tgz -export ETCBACKUP_DIR=/etc/backup -export INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt - -IMAGE="$1" - -[ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] && { +print_help() { cat <...] $0 [-q] [-i] [-c] [-u] [-o] [-k] @@ -102,9 +103,20 @@ backup-command: sysupgrade -b. Does not create a backup file. EOF - exit 1 } +IMAGE="$1" + +if [ $HELP -gt 0 ]; then + print_help + exit 0 +fi + +if [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 ]; then + print_help + exit 1 +fi + [ -n "$IMAGE" -a -n "$NEED_IMAGE" ] && { cat <<-EOF -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade. @@ -143,7 +155,7 @@ list_static_conffiles() { \( -type f -o -type l \) $filter 2>/dev/null } -add_conffiles() { +build_list_of_backup_config_files() { local file="$1" ( list_static_conffiles "$find_filter"; list_changed_conffiles ) | @@ -151,7 +163,7 @@ add_conffiles() { return 0 } -add_overlayfiles() { +build_list_of_backup_overlay_files() { local file="$1" local packagesfiles=$1.packagesfiles @@ -203,12 +215,12 @@ add_overlayfiles() { if [ $SAVE_OVERLAY = 1 ]; then [ ! -d /overlay/upper/etc ] && { - echo "Cannot find '/overlay/upper/etc', required for '-c'" >&2 + echo "Cannot find '/overlay/upper/etc', required for '-c' or '-o'" >&2 exit 1 } - sysupgrade_init_conffiles="add_overlayfiles" + sysupgrade_init_conffiles="build_list_of_backup_overlay_files" else - sysupgrade_init_conffiles="add_conffiles" + sysupgrade_init_conffiles="build_list_of_backup_config_files" fi find_filter="" @@ -222,8 +234,9 @@ fi include /lib/upgrade -do_save_conffiles() { +create_backup_archive() { local conf_tar="$1" + local disabled [ "$(rootfs_type)" = "tmpfs" ] && { echo "Cannot save config while running from ramdisk." >&2 @@ -234,41 +247,42 @@ do_save_conffiles() { run_hooks "$CONFFILES" $sysupgrade_init_conffiles ask_bool 0 "Edit config file list" && vi "$CONFFILES" - if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then - echo "${INSTALLED_PACKAGES}" >> "$CONFFILES" - mkdir -p "$ETCBACKUP_DIR" - # Avoid touching filesystem on each backup - RAMFS="$(mktemp -d -t sysupgrade.XXXXXX)" - mkdir -p "$RAMFS/upper" "$RAMFS/work" - mount -t overlay overlay -o lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work $ETCBACKUP_DIR && - UMOUNT_ETCBACKUP_DIR=1 || { - echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to avoid touching disk while saving the list of installed packages." >&2 - ask_bool 0 "Abort" && exit - } - - # Format: pkg-name{rom,overlay,unkown} - # rom is used for pkgs in /rom, even if updated later - find /usr/lib/opkg/info -name "*.control" \( \ - \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ - \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ - \( -exec echo {} unknown \; \) \ - \) | sed -e 's,.*/,,;s/\.control /\t/' > ${INSTALLED_PACKAGES} - fi - v "Saving config files..." [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" - tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null - if [ "$?" -ne 0 ]; then + sed -i -e 's,^/,,' "$CONFFILES" + { + for service in /etc/init.d/*; do + if ! $service enabled; then + disabled="$disabled$service disable\n" + fi + done + disabled="$disabled\nexit 0" + tar_print_member "/etc/uci-defaults/10_disable_services" "$(echo -e $disabled)" + + # Part of archive with installed packages info + if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then + # Format: pkg-name{rom,overlay,unknown} + # rom is used for pkgs in /rom, even if updated later + tar_print_member "$INSTALLED_PACKAGES" "$(find /usr/lib/opkg/info -name "*.control" \( \ + \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ + \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ + \( -exec echo {} unknown \; \) \ + \) | sed -e 's,.*/,,;s/\.control /\t/')" + fi + + # Rest of archive with config files and ending padding + tar c${TAR_V} -C / -T "$CONFFILES" + } | gzip > "$conf_tar" + + local err=$? + if [ "$err" -ne 0 ]; then echo "Failed to create the configuration backup." rm -f "$conf_tar" - exit 1 fi - [ "$UMOUNT_ETCBACKUP_DIR" -eq 1 ] && { - umount "$ETCBACKUP_DIR" - rm -rf "$RAMFS" - } rm -f "$CONFFILES" + + return "$err" } if [ $CONF_BACKUP_LIST -eq 1 ]; then @@ -280,8 +294,8 @@ if [ $CONF_BACKUP_LIST -eq 1 ]; then fi if [ -n "$CONF_BACKUP" ]; then - do_save_conffiles "$CONF_BACKUP" - exit $? + create_backup_archive "$CONF_BACKUP" + exit fi if [ -n "$CONF_RESTORE" ]; then @@ -350,7 +364,7 @@ if [ -n "$CONF_IMAGE" ]; then get_image "$CONF_IMAGE" "cat" > "$CONF_TAR" export SAVE_CONFIG=1 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then - [ $TEST -eq 1 ] || do_save_conffiles "$CONF_TAR" + [ $TEST -eq 1 ] || create_backup_archive "$CONF_TAR" || exit export SAVE_CONFIG=1 else [ $TEST -eq 1 ] || rm -f "$CONF_TAR" @@ -364,8 +378,6 @@ fi install_bin /sbin/upgraded v "Commencing upgrade. Closing all shell sessions." -COMMAND='/lib/upgrade/do_stage2' - if [ -n "$FAILSAFE" ]; then printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade lock -u /tmp/.failsafe diff --git a/package/boot/arm-trusted-firmware-mediatek/Makefile b/package/boot/arm-trusted-firmware-mediatek/Makefile index 259a987e6bf94f..abdd6e7e4a3895 100644 --- a/package/boot/arm-trusted-firmware-mediatek/Makefile +++ b/package/boot/arm-trusted-firmware-mediatek/Makefile @@ -26,12 +26,14 @@ include $(INCLUDE_DIR)/package.mk define Trusted-Firmware-A/Default BUILD_TARGET:=mediatek TFA_IMAGE:=bl2.img bl31.bin + HIDDEN:=y BOOT_DEVICE:= DDR3_FLYBY:= DDR_TYPE:= NAND_TYPE:= BOARD_QFN:= DRAM_USE_COMB:= + USE_UBI:= endef define Trusted-Firmware-A/mt7622-nor-1ddr @@ -56,6 +58,14 @@ define Trusted-Firmware-A/mt7622-snand-1ddr BOOT_DEVICE:=snand endef +define Trusted-Firmware-A/mt7622-snand-ubi-1ddr + NAME:=MediaTek MT7622 (SPI-NAND using UBI, 1x DDR3) + BUILD_SUBTARGET:=mt7622 + PLAT:=mt7622 + BOOT_DEVICE:=snand + USE_UBI:=1 +endef + define Trusted-Firmware-A/mt7622-snand-2ddr NAME:=MediaTek MT7622 (SPI-NAND, 2x DDR3) BUILD_SUBTARGET:=mt7622 @@ -64,6 +74,15 @@ define Trusted-Firmware-A/mt7622-snand-2ddr DDR3_FLYBY:=1 endef +define Trusted-Firmware-A/mt7622-snand-ubi-2ddr + NAME:=MediaTek MT7622 (SPI-NAND using UBI, 2x DDR3) + BUILD_SUBTARGET:=mt7622 + PLAT:=mt7622 + BOOT_DEVICE:=snand + DDR3_FLYBY:=1 + USE_UBI:=1 +endef + define Trusted-Firmware-A/mt7622-emmc-1ddr NAME:=MediaTek MT7622 (eMMC, 1x DDR3) BUILD_SUBTARGET:=mt7622 @@ -191,6 +210,16 @@ define Trusted-Firmware-A/mt7986-spim-nand-ddr4 NAND_TYPE:=spim:2k+64 endef +define Trusted-Firmware-A/mt7986-spim-nand-ubi-ddr4 + NAME:=MediaTek MT7986 (SPI-NAND via SPIM using UBI, DDR4) + BOOT_DEVICE:=spim-nand + BUILD_SUBTARGET:=filogic + PLAT:=mt7986 + DDR_TYPE:=ddr4 + NAND_TYPE:=spim:2k+64 + USE_UBI:=1 +endef + define Trusted-Firmware-A/mt7986-spim-nand-4k-ddr4 NAME:=MediaTek MT7986 (SPI-NAND via SPIM, DDR4) BOOT_DEVICE:=spim-nand @@ -352,6 +381,15 @@ define Trusted-Firmware-A/mt7988-snand-comb DRAM_USE_COMB:=1 endef +define Trusted-Firmware-A/mt7988-snand-ubi-comb + NAME:=MediaTek MT7988 (SPI-NAND via SNFI, UBI) + BOOT_DEVICE:=snand + BUILD_SUBTARGET:=filogic + PLAT:=mt7988 + DRAM_USE_COMB:=1 + USE_UBI:=1 +endef + define Trusted-Firmware-A/mt7988-spim-nand-comb NAME:=MediaTek MT7988 (SPI-NAND via SPIM) BOOT_DEVICE:=spim-nand @@ -360,11 +398,22 @@ define Trusted-Firmware-A/mt7988-spim-nand-comb DRAM_USE_COMB:=1 endef +define Trusted-Firmware-A/mt7988-spim-nand-ubi-comb + NAME:=MediaTek MT7988 (SPI-NAND via SPIM, UBI) + BOOT_DEVICE:=spim-nand + BUILD_SUBTARGET:=filogic + PLAT:=mt7988 + DRAM_USE_COMB:=1 + USE_UBI:=1 +endef + TFA_TARGETS:= \ mt7622-nor-1ddr \ mt7622-nor-2ddr \ mt7622-snand-1ddr \ + mt7622-snand-ubi-1ddr \ mt7622-snand-2ddr \ + mt7622-snand-ubi-2ddr \ mt7622-emmc-1ddr \ mt7622-emmc-2ddr \ mt7622-sdmmc-1ddr \ @@ -386,6 +435,7 @@ TFA_TARGETS:= \ mt7986-sdmmc-ddr4 \ mt7986-snand-ddr4 \ mt7986-spim-nand-ddr4 \ + mt7986-spim-nand-ubi-ddr4 \ mt7986-spim-nand-4k-ddr4 \ mt7988-emmc-ddr3 \ mt7988-nor-ddr3 \ @@ -401,7 +451,9 @@ TFA_TARGETS:= \ mt7988-nor-comb \ mt7988-sdmmc-comb \ mt7988-snand-comb \ - mt7988-spim-nand-comb + mt7988-snand-ubi-comb \ + mt7988-spim-nand-comb \ + mt7988-spim-nand-ubi-comb TFA_MAKE_FLAGS += \ BOOT_DEVICE=$(BOOT_DEVICE) \ @@ -412,6 +464,7 @@ TFA_MAKE_FLAGS += \ HAVE_DRAM_OBJ_FILE=yes \ $(if $(DDR3_FLYBY),DDR3_FLYBY=1) \ $(if $(DRAM_USE_COMB),DRAM_USE_COMB=1) \ + $(if $(USE_UBI),UBI=1 $(if $(findstring mt7622,$(PLAT)),OVERRIDE_UBI_START_ADDR=0x80000)) \ all define Package/trusted-firmware-a/install diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile index 7f06ec7d642f9f..702ae009030091 100644 --- a/package/boot/kexec-tools/Makefile +++ b/package/boot/kexec-tools/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=kexec-tools -PKG_VERSION:=2.0.26 +PKG_VERSION:=2.0.28 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec -PKG_HASH:=7fe36a064101cd5c515e41b2be393dce3ca88adce59d6ee668e0af7c0c4570cd +PKG_HASH:=d2f0ef872f39e2fe4b1b01feb62b0001383207239b9f8041f98a95564161d053 PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA diff --git a/package/boot/opensbi/Makefile b/package/boot/opensbi/Makefile index 01348e50aad4a8..6bb33ad2aa02ac 100644 --- a/package/boot/opensbi/Makefile +++ b/package/boot/opensbi/Makefile @@ -29,7 +29,7 @@ include $(INCLUDE_DIR)/package.mk define Package/opensbi SECTION:=boot CATEGORY:=Boot Loaders - DEPENDS:=@TARGET_sifiveu + DEPENDS:=@(TARGET_sifiveu||TARGET_d1) URL:=https://github.com/riscv/opensbi/blob/master/README.md VARIANT:=$(subst _,/,$(subst opensbi_,,$(1))) TITLE:=OpenSBI generic diff --git a/package/boot/rkbin/Makefile b/package/boot/rkbin/Makefile index affdd7b4e19206..bb116bdcd2b8de 100644 --- a/package/boot/rkbin/Makefile +++ b/package/boot/rkbin/Makefile @@ -25,6 +25,12 @@ define Trusted-Firmware-A/Default BUILD_TARGET:=rockchip endef +define Trusted-Firmware-A/rk3566 + BUILD_SUBTARGET:=armv8 + ATF:=rk35/rk3568_bl31_v1.43.elf + TPL:=rk35/rk3566_ddr_1056MHz_v1.18.bin +endef + define Trusted-Firmware-A/rk3568 BUILD_SUBTARGET:=armv8 ATF:=rk35/rk3568_bl31_v1.43.elf @@ -32,6 +38,7 @@ define Trusted-Firmware-A/rk3568 endef TFA_TARGETS:= \ + rk3566 \ rk3568 define Build/Compile diff --git a/package/boot/uboot-d1/Makefile b/package/boot/uboot-d1/Makefile new file mode 100644 index 00000000000000..610dc5b49856dc --- /dev/null +++ b/package/boot/uboot-d1/Makefile @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2023 OpenWrt.org +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_VERSION:=2023.01 +PKG_RELEASE:=1 + +PKG_HASH:=69423bad380f89a0916636e89e6dcbd2e4512d584308d922d1039d1e4331950f + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +define U-Boot/Default + BUILD_TARGET:=d1 + UBOOT_IMAGE:=u-boot-sunxi-with-spl.bin + UENV:=default + DTS_DIR:=arch/riscv/dts +endef + +define U-Boot/dongshan_nezha_stu + NAME:=Dongshan Nezha STU + OPENSBI:=generic + DEPENDS:=+opensbi_generic + UBOOT_DTS:=sun20i-d1-dongshan-nezha-stu.dtb + BUILD_DEVICES:=dongshan_nezha_stu +endef + +define U-Boot/lichee_rv_dock + NAME:=LicheePi RV (dock) + OPENSBI:=generic + DEPENDS:=+opensbi_generic + UBOOT_DTS:=sun20i-d1-lichee-rv-dock.dtb + BUILD_DEVICES:=lichee_rv_dock +endef + +define U-Boot/mangopi_mq_pro + NAME:=MangoPi MQ Pro + OPENSBI:=generic + DEPENDS:=+opensbi_generic + UBOOT_DTS:=sun20i-d1-mangopi-mq-pro.dtb + BUILD_DEVICES:=mangopi_mq_pro +endef + +define U-Boot/nezha + NAME:=Nezha D1 + OPENSBI:=generic + DEPENDS:=+opensbi_generic + UBOOT_DTS:=sun20i-d1-nezha.dtb + BUILD_DEVICES:=nezha +endef + +UBOOT_TARGETS := \ + dongshan_nezha_stu \ + lichee_rv_dock \ + mangopi_mq_pro \ + nezha \ + +UBOOT_MAKE_FLAGS += \ + OPENSBI=$(STAGING_DIR_IMAGE)/fw_dynamic-${OPENSBI}.bin + +define Build/Configure + $(call Build/Configure/U-Boot) + sed -i 's/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/' $(PKG_BUILD_DIR)/.config +endef + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(DTS_DIR)/$(UBOOT_DTS) $(STAGING_DIR_IMAGE)/$(UBOOT_DTS) + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-$(UBOOT_IMAGE) + mkimage -C none -A riscv -T script -d uEnv-$(UENV).txt \ + $(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-boot.scr +endef + +define Package/u-boot/install/default +endef + +$(eval $(call BuildPackage/U-Boot)) diff --git a/package/boot/uboot-d1/patches/0001-ARM-dts-sun8i-A33-Add-iNet-U70B-REV01.patch b/package/boot/uboot-d1/patches/0001-ARM-dts-sun8i-A33-Add-iNet-U70B-REV01.patch new file mode 100644 index 00000000000000..1dc6468c4b4e1b --- /dev/null +++ b/package/boot/uboot-d1/patches/0001-ARM-dts-sun8i-A33-Add-iNet-U70B-REV01.patch @@ -0,0 +1,197 @@ +From d45e64aad18e5e324425b9efbe6a0ec9e1a343da Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 20 Nov 2021 13:19:13 -0600 +Subject: [PATCH 01/90] ARM: dts: sun8i: A33: Add iNet U70B REV01 + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/Makefile | 1 + + arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts | 172 ++++++++++++++++++++++ + 2 files changed, 173 insertions(+) + create mode 100644 arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts + +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -644,6 +644,7 @@ dtb-$(CONFIG_MACH_SUN8I_A33) += \ + sun8i-a33-et-q8-v1.6.dtb \ + sun8i-a33-ga10h-v1.1.dtb \ + sun8i-a33-inet-d978-rev2.dtb \ ++ sun8i-a33-inet-u70b-rev1.dtb \ + sun8i-a33-ippo-q8h-v1.2.dtb \ + sun8i-a33-olinuxino.dtb \ + sun8i-a33-q8-tablet.dtb \ +--- /dev/null ++++ b/arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts +@@ -0,0 +1,172 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++ ++/dts-v1/; ++ ++#include "sun8i-a33.dtsi" ++#include "sun8i-reference-design-tablet.dtsi" ++ ++/ { ++ model = "iNet U70B REV01"; ++ compatible = "inet-tek,inet-u70b-rev01", "allwinner,sun8i-a33"; ++ ++ aliases { ++ ethernet0 = &rtl8723cs; ++ }; ++ ++ panel: panel { ++ compatible = "panel-dpi"; ++ backlight = <&backlight>; ++ enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */ ++ power-supply = <®_dc1sw>; ++ ++ panel-timing { ++ clock-frequency = <51000000>; ++ hactive = <1024>; ++ vactive = <600>; ++ hfront-porch = <162>; ++ hback-porch = <158>; ++ hsync-len = <20>; ++ vback-porch = <25>; ++ vfront-porch = <10>; ++ vsync-len = <3>; ++ hsync-active = <1>; ++ vsync-active = <1>; ++ }; ++ ++ port { ++ panel_in_tcon0: endpoint { ++ remote-endpoint = <&tcon0_out_panel>; ++ }; ++ }; ++ }; ++ ++ speaker_amp: audio-amplifier { ++ compatible = "simple-audio-amplifier"; ++ enable-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */ ++ sound-name-prefix = "Speaker Amp"; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&r_pio 0 6 GPIO_ACTIVE_LOW>; /* PL6 */ ++ post-power-on-delay-ms = <200>; ++ }; ++}; ++ ++&codec { ++ status = "okay"; ++}; ++ ++&dai { ++ status = "okay"; ++}; ++ ++&de { ++ status = "okay"; ++}; ++ ++&i2c1 { ++ clock-frequency = <400000>; ++ ++ accelerometer@18 { ++ compatible = "bosch,bma250"; ++ reg = <0x18>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 10 IRQ_TYPE_EDGE_RISING>; /* PH10 / EINT10 */ ++ }; ++}; ++ ++&mmc1 { ++ pinctrl-0 = <&mmc1_pg_pins>; ++ pinctrl-names = "default"; ++ bus-width = <4>; ++ non-removable; ++ vmmc-supply = <®_dldo1>; ++ vqmmc-supply = <®_dldo2>; ++ status = "okay"; ++ ++ rtl8723cs: wifi@1 { ++ reg = <1>; ++ interrupt-parent = <&r_pio>; ++ interrupts = <0 7 IRQ_TYPE_LEVEL_LOW>; /* PL7 */ ++ }; ++}; ++ ++&nfc { ++ status = "okay"; ++ ++ nand@0 { ++ reg = <0>; ++ allwinner,rb = <0>; ++ nand-ecc-maximize; ++ }; ++}; ++ ++&r_uart { ++ status = "disabled"; ++}; ++ ++®_dldo2 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-wifi-io"; ++}; ++ ++&simplefb_lcd { ++ status = "okay"; ++}; ++ ++&sound { ++ simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>; ++ simple-audio-card,widgets = "Headphone", "Headphone Jack", ++ "Microphone", "Internal Microphone", ++ "Speaker", "Internal Speaker"; ++ simple-audio-card,routing = "Headphone Jack", "HP", ++ "Internal Speaker", "Speaker Amp OUTL", ++ "Internal Speaker", "Speaker Amp OUTR", ++ "Speaker Amp INL", "HP", /* PHONEOUT ??? */ ++ "Speaker Amp INR", "HP", /* PHONEOUT ??? */ ++ "Left DAC", "DACL", ++ "Right DAC", "DACR", ++ "ADCL", "Left ADC", ++ "ADCR", "Right ADC", ++ "MIC1", "Internal Microphone", ++ "MIC2", "Headset Microphone", ++ "Headset Microphone", "HBIAS", ++ "Internal Microphone", "MBIAS"; ++ status = "okay"; ++}; ++ ++&tcon0 { ++ pinctrl-0 = <&lcd_rgb666_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&tcon0_out { ++ tcon0_out_panel: endpoint { ++ remote-endpoint = <&panel_in_tcon0>; ++ }; ++}; ++ ++&touchscreen { ++ reg = <0x40>; ++ compatible = "silead,gsl1680"; ++ avdd-supply = <®_ldo_io1>; ++ touchscreen-size-x = <1024>; ++ touchscreen-size-y = <600>; ++ status = "okay"; ++}; ++ ++&uart1 { ++ pinctrl-0 = <&uart1_pg_pins>, <&uart1_cts_rts_pg_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ bluetooth { ++ compatible = "realtek,rtl8723cs-bt"; ++ device-wake-gpios = <&r_pio 0 10 GPIO_ACTIVE_LOW>; /* PL10 */ ++ enable-gpios = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */ ++ host-wake-gpios = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */ ++ }; ++}; diff --git a/package/boot/uboot-d1/patches/0002-sunxi-Add-iNet_U70B_rev1_defconfig.patch b/package/boot/uboot-d1/patches/0002-sunxi-Add-iNet_U70B_rev1_defconfig.patch new file mode 100644 index 00000000000000..40f649b7fe25da --- /dev/null +++ b/package/boot/uboot-d1/patches/0002-sunxi-Add-iNet_U70B_rev1_defconfig.patch @@ -0,0 +1,46 @@ +From ddb1f06d1c7758c538e286c0c7a9c8545d2af6b1 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 20 Nov 2021 13:26:36 -0600 +Subject: [PATCH 02/90] sunxi: Add iNet_U70B_rev1_defconfig + +Signed-off-by: Samuel Holland +--- + configs/iNet_U70B_rev1_defconfig | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + create mode 100644 configs/iNet_U70B_rev1_defconfig + +--- /dev/null ++++ b/configs/iNet_U70B_rev1_defconfig +@@ -0,0 +1,32 @@ ++CONFIG_ARM=y ++CONFIG_ARCH_SUNXI=y ++CONFIG_DEFAULT_DEVICE_TREE="sun8i-a33-inet-u70b-rev1" ++# CONFIG_SPL_SERIAL is not set ++CONFIG_SPL=y ++CONFIG_MACH_SUN8I_A33=y ++CONFIG_DRAM_CLK=480 ++CONFIG_DRAM_ZQ=31675 ++CONFIG_DRAM_ODT_EN=y ++CONFIG_MMC0_CD_PIN="PB4" ++CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:51000,le:158,ri:162,up:25,lo:10,hs:20,vs:3,sync:3,vmode:0" ++CONFIG_VIDEO_LCD_DCLK_PHASE=0 ++CONFIG_VIDEO_LCD_POWER="PH7" ++CONFIG_VIDEO_LCD_BL_EN="PH6" ++CONFIG_VIDEO_LCD_BL_PWM="PH0" ++# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set ++CONFIG_CMD_BIND=y ++CONFIG_CMD_CLK=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_I2C=y ++CONFIG_CMD_WDT=y ++CONFIG_CMD_PMIC=y ++CONFIG_CMD_REGULATOR=y ++# CONFIG_NET is not set ++CONFIG_AXP_GPIO=y ++CONFIG_REGULATOR_AXP=y ++CONFIG_REGULATOR_AXP_USB_POWER=y ++CONFIG_AXP_DLDO1_VOLT=3300 ++CONFIG_DM_PWM=y ++CONFIG_PWM_SUNXI=y ++# CONFIG_REQUIRE_SERIAL_CONSOLE is not set ++CONFIG_USB_MUSB_HOST=y diff --git a/package/boot/uboot-d1/patches/0003-Adapt-iNet-U70B-REV01-for-development-FEL-serial.patch b/package/boot/uboot-d1/patches/0003-Adapt-iNet-U70B-REV01-for-development-FEL-serial.patch new file mode 100644 index 00000000000000..03f1ca11754645 --- /dev/null +++ b/package/boot/uboot-d1/patches/0003-Adapt-iNet-U70B-REV01-for-development-FEL-serial.patch @@ -0,0 +1,85 @@ +From ef808412055d1ef6fe77ff130d3f5a9432fef2d7 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Tue, 3 May 2022 22:35:12 -0500 +Subject: [PATCH 03/90] Adapt iNet U70B REV01 for development (FEL + serial) + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts | 11 +++++++++++ + configs/iNet_U70B_rev1_defconfig | 14 +++++--------- + 2 files changed, 16 insertions(+), 9 deletions(-) + +--- a/arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts ++++ b/arch/arm/dts/sun8i-a33-inet-u70b-rev1.dts +@@ -11,6 +11,7 @@ + + aliases { + ethernet0 = &rtl8723cs; ++ serial0 = &uart0; + }; + + panel: panel { +@@ -76,6 +77,10 @@ + }; + }; + ++&mmc0 { ++ status = "disabled"; ++}; ++ + &mmc1 { + pinctrl-0 = <&mmc1_pg_pins>; + pinctrl-names = "default"; +@@ -158,6 +163,12 @@ + status = "okay"; + }; + ++&uart0 { ++ pinctrl-0 = <&uart0_pf_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &uart1 { + pinctrl-0 = <&uart1_pg_pins>, <&uart1_cts_rts_pg_pins>; + pinctrl-names = "default"; +--- a/configs/iNet_U70B_rev1_defconfig ++++ b/configs/iNet_U70B_rev1_defconfig +@@ -1,12 +1,12 @@ + CONFIG_ARM=y + CONFIG_ARCH_SUNXI=y + CONFIG_DEFAULT_DEVICE_TREE="sun8i-a33-inet-u70b-rev1" +-# CONFIG_SPL_SERIAL is not set + CONFIG_SPL=y + CONFIG_MACH_SUN8I_A33=y + CONFIG_DRAM_CLK=480 + CONFIG_DRAM_ZQ=31675 + CONFIG_DRAM_ODT_EN=y ++CONFIG_UART0_PORT_F=y + CONFIG_MMC0_CD_PIN="PB4" + CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:51000,le:158,ri:162,up:25,lo:10,hs:20,vs:3,sync:3,vmode:0" + CONFIG_VIDEO_LCD_DCLK_PHASE=0 +@@ -14,19 +14,15 @@ CONFIG_VIDEO_LCD_POWER="PH7" + CONFIG_VIDEO_LCD_BL_EN="PH6" + CONFIG_VIDEO_LCD_BL_PWM="PH0" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +-CONFIG_CMD_BIND=y +-CONFIG_CMD_CLK=y +-CONFIG_CMD_PWM=y +-CONFIG_CMD_I2C=y +-CONFIG_CMD_WDT=y ++CONFIG_PREBOOT="fastboot usb 0" + CONFIG_CMD_PMIC=y + CONFIG_CMD_REGULATOR=y +-# CONFIG_NET is not set + CONFIG_AXP_GPIO=y + CONFIG_REGULATOR_AXP=y + CONFIG_REGULATOR_AXP_USB_POWER=y + CONFIG_AXP_DLDO1_VOLT=3300 + CONFIG_DM_PWM=y + CONFIG_PWM_SUNXI=y +-# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +-CONFIG_USB_MUSB_HOST=y ++CONFIG_REMOTEPROC_SUN6I_AR100=y ++CONFIG_USB_MUSB_GADGET=y ++CONFIG_WATCHDOG_AUTOSTART=y diff --git a/package/boot/uboot-d1/patches/0004-ARM-dts-sun6i-mixtile-loftq-Add-USB1-VBUS-regulator.patch b/package/boot/uboot-d1/patches/0004-ARM-dts-sun6i-mixtile-loftq-Add-USB1-VBUS-regulator.patch new file mode 100644 index 00000000000000..b6685936ad44fb --- /dev/null +++ b/package/boot/uboot-d1/patches/0004-ARM-dts-sun6i-mixtile-loftq-Add-USB1-VBUS-regulator.patch @@ -0,0 +1,54 @@ +From 40a0ec0fdb6a110d69151de5480148772877f267 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 20:39:33 -0500 +Subject: [PATCH 04/90] ARM: dts: sun6i: mixtile-loftq: Add USB1 VBUS regulator + +This board is configured with CONFIG_USB1_VBUS_PIN="PH24", but no +regulator exists in its device tree. Add the regulator, so USB will +continue to work when the PHY driver switches to using the regulator +uclass instead of a GPIO. + +Update the device tree here because it does not exist in Linux. + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/sun6i-a31-mixtile-loftq.dts | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +--- a/arch/arm/dts/sun6i-a31-mixtile-loftq.dts ++++ b/arch/arm/dts/sun6i-a31-mixtile-loftq.dts +@@ -6,6 +6,9 @@ + */ + + /dts-v1/; ++ ++#include ++ + #include "sun6i-a31.dtsi" + + / { +@@ -19,6 +22,15 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ reg_usb1_vbus: usb1-vbus { ++ compatible = "regulator-fixed"; ++ regulator-name = "usb1-vbus"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ enable-active-high; ++ gpio = <&pio 7 24 GPIO_ACTIVE_HIGH>; /* PH24 */ ++ }; + }; + + &ehci0 { +@@ -56,3 +68,8 @@ + pinctrl-0 = <&uart0_ph_pins>; + status = "okay"; + }; ++ ++&usbphy { ++ usb1_vbus-supply = <®_usb1_vbus>; ++ status = "okay"; ++}; diff --git a/package/boot/uboot-d1/patches/0005-power-regulator-Add-a-driver-for-the-AXP-USB-power-s.patch b/package/boot/uboot-d1/patches/0005-power-regulator-Add-a-driver-for-the-AXP-USB-power-s.patch new file mode 100644 index 00000000000000..62f81e3cd6137a --- /dev/null +++ b/package/boot/uboot-d1/patches/0005-power-regulator-Add-a-driver-for-the-AXP-USB-power-s.patch @@ -0,0 +1,97 @@ +From e07c1d516c1a7842510d22a7cf88666d500a9a9a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 22 Aug 2021 21:35:45 -0500 +Subject: [PATCH 05/90] power: regulator: Add a driver for the AXP USB power + supply + +This driver reports the presence/absence of voltage on the PMIC's USB +VBUS pin. This information is used by the USB PHY driver. The +corresponding Linux driver uses the power supply class, which does not +exist in U-Boot. UCLASS_REGULATOR seems to be the closest match. + +Signed-off-by: Samuel Holland +--- + drivers/power/regulator/Kconfig | 7 ++++ + drivers/power/regulator/Makefile | 1 + + drivers/power/regulator/axp_usb_power.c | 49 +++++++++++++++++++++++++ + 3 files changed, 57 insertions(+) + create mode 100644 drivers/power/regulator/axp_usb_power.c + +--- a/drivers/power/regulator/Kconfig ++++ b/drivers/power/regulator/Kconfig +@@ -43,6 +43,13 @@ config REGULATOR_AS3722 + but does not yet support change voltages. Currently this must be + done using direct register writes to the PMIC. + ++config REGULATOR_AXP_USB_POWER ++ bool "Enable driver for X-Powers AXP PMIC USB power supply" ++ depends on DM_REGULATOR && PMIC_AXP ++ help ++ Enable support for reading the USB power supply status from ++ X-Powers AXP2xx and AXP8xx PMICs. ++ + config DM_REGULATOR_BD71837 + bool "Enable Driver Model for ROHM BD71837/BD71847 regulators" + depends on DM_REGULATOR && DM_PMIC_BD71837 +--- a/drivers/power/regulator/Makefile ++++ b/drivers/power/regulator/Makefile +@@ -7,6 +7,7 @@ + obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o + obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o + obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o ++obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o + obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o + obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o + obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o +--- /dev/null ++++ b/drivers/power/regulator/axp_usb_power.c +@@ -0,0 +1,49 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++#include ++#include ++#include ++#include ++ ++#define AXP_POWER_STATUS 0x00 ++#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) ++ ++static int axp_usb_power_get_enable(struct udevice *dev) ++{ ++ int ret; ++ ++ ret = pmic_reg_read(dev->parent, AXP_POWER_STATUS); ++ if (ret < 0) ++ return ret; ++ ++ return !!(ret & AXP_POWER_STATUS_VBUS_PRESENT); ++} ++ ++static const struct dm_regulator_ops axp_usb_power_ops = { ++ .get_enable = axp_usb_power_get_enable, ++}; ++ ++static int axp_usb_power_probe(struct udevice *dev) ++{ ++ struct dm_regulator_uclass_plat *uc_plat = dev_get_uclass_plat(dev); ++ ++ uc_plat->type = REGULATOR_TYPE_FIXED; ++ ++ return 0; ++} ++ ++static const struct udevice_id axp_usb_power_ids[] = { ++ { .compatible = "x-powers,axp202-usb-power-supply" }, ++ { .compatible = "x-powers,axp221-usb-power-supply" }, ++ { .compatible = "x-powers,axp223-usb-power-supply" }, ++ { .compatible = "x-powers,axp813-usb-power-supply" }, ++ { } ++}; ++ ++U_BOOT_DRIVER(axp_usb_power) = { ++ .name = "axp_usb_power", ++ .id = UCLASS_REGULATOR, ++ .of_match = axp_usb_power_ids, ++ .probe = axp_usb_power_probe, ++ .ops = &axp_usb_power_ops, ++}; diff --git a/package/boot/uboot-d1/patches/0006-gpio-axp-sunxi-Remove-virtual-VBUS-detection-GPIO.patch b/package/boot/uboot-d1/patches/0006-gpio-axp-sunxi-Remove-virtual-VBUS-detection-GPIO.patch new file mode 100644 index 00000000000000..e890583beae996 --- /dev/null +++ b/package/boot/uboot-d1/patches/0006-gpio-axp-sunxi-Remove-virtual-VBUS-detection-GPIO.patch @@ -0,0 +1,122 @@ +From c750151e1107a8d46ca0f9bd30c1da276b142ec1 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 18:02:54 -0500 +Subject: [PATCH 06/90] gpio: axp/sunxi: Remove virtual VBUS detection GPIO + +Now that this functionality is modeled using the device tree and +regulator uclass, the named GPIO is not referenced anywhere. Remove it. + +Signed-off-by: Samuel Holland +--- + arch/arm/include/asm/arch-sunxi/gpio.h | 1 - + drivers/gpio/axp_gpio.c | 21 ++++----------------- + drivers/gpio/sunxi_gpio.c | 6 +----- + include/axp209.h | 1 - + include/axp221.h | 1 - + include/axp809.h | 1 - + include/axp818.h | 1 - + 7 files changed, 5 insertions(+), 27 deletions(-) + +--- a/arch/arm/include/asm/arch-sunxi/gpio.h ++++ b/arch/arm/include/asm/arch-sunxi/gpio.h +@@ -209,7 +209,6 @@ enum sunxi_gpio_number { + + /* Virtual AXP0 GPIOs */ + #define SUNXI_GPIO_AXP0_PREFIX "AXP0-" +-#define SUNXI_GPIO_AXP0_VBUS_DETECT 4 + #define SUNXI_GPIO_AXP0_VBUS_ENABLE 5 + #define SUNXI_GPIO_AXP0_GPIO_COUNT 6 + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -36,18 +36,11 @@ static int axp_gpio_direction_input(stru + { + u8 reg; + +- switch (pin) { +-#ifndef CONFIG_AXP152_POWER /* NA on axp152 */ +- case SUNXI_GPIO_AXP0_VBUS_DETECT: +- return 0; +-#endif +- default: +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; ++ reg = axp_get_gpio_ctrl_reg(pin); ++ if (reg == 0) ++ return -EINVAL; + +- return pmic_bus_write(reg, AXP_GPIO_CTRL_INPUT); +- } ++ return pmic_bus_write(reg, AXP_GPIO_CTRL_INPUT); + } + + static int axp_gpio_direction_output(struct udevice *dev, unsigned pin, +@@ -83,12 +76,6 @@ static int axp_gpio_get_value(struct ude + int ret; + + switch (pin) { +-#ifndef CONFIG_AXP152_POWER /* NA on axp152 */ +- case SUNXI_GPIO_AXP0_VBUS_DETECT: +- ret = pmic_bus_read(AXP_POWER_STATUS, &val); +- mask = AXP_POWER_STATUS_VBUS_PRESENT; +- break; +-#endif + #ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC + /* Only available on later PMICs */ + case SUNXI_GPIO_AXP0_VBUS_ENABLE: +--- a/drivers/gpio/sunxi_gpio.c ++++ b/drivers/gpio/sunxi_gpio.c +@@ -117,11 +117,7 @@ int sunxi_name_to_gpio(const char *name) + #if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO + char lookup[8]; + +- if (strcasecmp(name, "AXP0-VBUS-DETECT") == 0) { +- sprintf(lookup, SUNXI_GPIO_AXP0_PREFIX "%d", +- SUNXI_GPIO_AXP0_VBUS_DETECT); +- name = lookup; +- } else if (strcasecmp(name, "AXP0-VBUS-ENABLE") == 0) { ++ if (strcasecmp(name, "AXP0-VBUS-ENABLE") == 0) { + sprintf(lookup, SUNXI_GPIO_AXP0_PREFIX "%d", + SUNXI_GPIO_AXP0_VBUS_ENABLE); + name = lookup; +--- a/include/axp209.h ++++ b/include/axp209.h +@@ -77,7 +77,6 @@ enum axp209_reg { + #ifdef CONFIG_AXP209_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + #define AXP_GPIO0_CTRL 0x90 + #define AXP_GPIO1_CTRL 0x92 + #define AXP_GPIO2_CTRL 0x93 +--- a/include/axp221.h ++++ b/include/axp221.h +@@ -53,7 +53,6 @@ + #ifdef CONFIG_AXP221_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + #define AXP_VBUS_IPSOUT 0x30 + #define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) + #define AXP_MISC_CTRL 0x8f +--- a/include/axp809.h ++++ b/include/axp809.h +@@ -47,7 +47,6 @@ + #ifdef CONFIG_AXP809_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + #define AXP_VBUS_IPSOUT 0x30 + #define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) + #define AXP_MISC_CTRL 0x8f +--- a/include/axp818.h ++++ b/include/axp818.h +@@ -61,7 +61,6 @@ + #ifdef CONFIG_AXP818_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + #define AXP_VBUS_IPSOUT 0x30 + #define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) + #define AXP_MISC_CTRL 0x8f diff --git a/package/boot/uboot-d1/patches/0007-power-regulator-Add-a-driver-for-the-AXP-PMIC-drivev.patch b/package/boot/uboot-d1/patches/0007-power-regulator-Add-a-driver-for-the-AXP-PMIC-drivev.patch new file mode 100644 index 00000000000000..35b4597f9851c7 --- /dev/null +++ b/package/boot/uboot-d1/patches/0007-power-regulator-Add-a-driver-for-the-AXP-PMIC-drivev.patch @@ -0,0 +1,111 @@ +From 25434a394705d2de92c50981e31347db4074204a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 21:32:15 -0500 +Subject: [PATCH 07/90] power: regulator: Add a driver for the AXP PMIC + drivevbus + +The first AXP regulator converted to use the regulator uclass is the +drivevbus switch, since it is used by the USB PHY driver. + +Signed-off-by: Samuel Holland +--- + drivers/power/regulator/Kconfig | 14 ++++++ + drivers/power/regulator/Makefile | 1 + + drivers/power/regulator/axp_regulator.c | 58 +++++++++++++++++++++++++ + 3 files changed, 73 insertions(+) + create mode 100644 drivers/power/regulator/axp_regulator.c + +--- a/drivers/power/regulator/Kconfig ++++ b/drivers/power/regulator/Kconfig +@@ -43,6 +43,20 @@ config REGULATOR_AS3722 + but does not yet support change voltages. Currently this must be + done using direct register writes to the PMIC. + ++config REGULATOR_AXP ++ bool "Enable driver for X-Powers AXP PMIC regulators" ++ depends on DM_REGULATOR && PMIC_AXP ++ help ++ Enable support for the regulators (DCDCs, LDOs) in the ++ X-Powers AXP152, AXP2xx, and AXP8xx PMICs. ++ ++config SPL_REGULATOR_AXP ++ bool "Enable driver for X-Powers AXP PMIC regulators in SPL" ++ depends on SPL_DM_REGULATOR && SPL_PMIC_AXP ++ help ++ Enable support in SPL for the regulators (DCDCs, LDOs) in the ++ X-Powers AXP152, AXP2xx, and AXP8xx PMICs. ++ + config REGULATOR_AXP_USB_POWER + bool "Enable driver for X-Powers AXP PMIC USB power supply" + depends on DM_REGULATOR && PMIC_AXP +--- a/drivers/power/regulator/Makefile ++++ b/drivers/power/regulator/Makefile +@@ -7,6 +7,7 @@ + obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o + obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o + obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o ++obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o + obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o + obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o + obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o +--- /dev/null ++++ b/drivers/power/regulator/axp_regulator.c +@@ -0,0 +1,58 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++#include ++#include ++#include ++#include ++ ++#define AXP_VBUS_IPSOUT 0x30 ++#define AXP_VBUS_IPSOUT_DRIVEBUS BIT(2) ++#define AXP_MISC_CTRL 0x8f ++#define AXP_MISC_CTRL_N_VBUSEN_FUNC BIT(4) ++ ++static int axp_drivevbus_get_enable(struct udevice *dev) ++{ ++ int ret; ++ ++ ret = pmic_reg_read(dev->parent, AXP_VBUS_IPSOUT); ++ if (ret < 0) ++ return ret; ++ ++ return !!(ret & AXP_VBUS_IPSOUT_DRIVEBUS); ++} ++ ++static int axp_drivevbus_set_enable(struct udevice *dev, bool enable) ++{ ++ return pmic_clrsetbits(dev->parent, AXP_VBUS_IPSOUT, ++ AXP_VBUS_IPSOUT_DRIVEBUS, ++ enable ? AXP_VBUS_IPSOUT_DRIVEBUS : 0); ++} ++ ++static const struct dm_regulator_ops axp_drivevbus_ops = { ++ .get_enable = axp_drivevbus_get_enable, ++ .set_enable = axp_drivevbus_set_enable, ++}; ++ ++static int axp_drivevbus_probe(struct udevice *dev) ++{ ++ struct dm_regulator_uclass_plat *uc_plat = dev_get_uclass_plat(dev); ++ int ret; ++ ++ uc_plat->type = REGULATOR_TYPE_FIXED; ++ ++ if (dev_read_bool(dev->parent, "x-powers,drive-vbus-en")) { ++ ret = pmic_clrsetbits(dev->parent, AXP_MISC_CTRL, ++ AXP_MISC_CTRL_N_VBUSEN_FUNC, 0); ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++U_BOOT_DRIVER(axp_drivevbus) = { ++ .name = "axp_drivevbus", ++ .id = UCLASS_REGULATOR, ++ .probe = axp_drivevbus_probe, ++ .ops = &axp_drivevbus_ops, ++}; diff --git a/package/boot/uboot-d1/patches/0008-power-pmic-axp-Probe-the-drivevbus-regulator-from-th.patch b/package/boot/uboot-d1/patches/0008-power-pmic-axp-Probe-the-drivevbus-regulator-from-th.patch new file mode 100644 index 00000000000000..2e8ed790ded419 --- /dev/null +++ b/package/boot/uboot-d1/patches/0008-power-pmic-axp-Probe-the-drivevbus-regulator-from-th.patch @@ -0,0 +1,41 @@ +From a588c97f146b67bae47099bc419cf10c02eca169 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 21:34:33 -0500 +Subject: [PATCH 08/90] power: pmic: axp: Probe the drivevbus regulator from + the DT + +Now that some regulator driver exists for this PMIC, add support for +probing regulator drivers from the device tree subnodes. + +Signed-off-by: Samuel Holland +--- + drivers/power/pmic/axp.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/power/pmic/axp.c ++++ b/drivers/power/pmic/axp.c +@@ -45,14 +45,24 @@ static struct dm_pmic_ops axp_pmic_ops = + .write = dm_i2c_write, + }; + ++static const struct pmic_child_info axp_pmic_child_info[] = { ++ { "drivevbus", "axp_drivevbus" }, ++ { } ++}; ++ + static int axp_pmic_bind(struct udevice *dev) + { ++ ofnode regulators_node; + int ret; + + ret = dm_scan_fdt_dev(dev); + if (ret) + return ret; + ++ regulators_node = dev_read_subnode(dev, "regulators"); ++ if (ofnode_valid(regulators_node)) ++ pmic_bind_children(dev, regulators_node, axp_pmic_child_info); ++ + if (CONFIG_IS_ENABLED(SYSRESET)) { + ret = device_bind_driver_to_node(dev, "axp_sysreset", "axp_sysreset", + dev_ofnode(dev), NULL); diff --git a/package/boot/uboot-d1/patches/0009-phy-sun4i-usb-Control-USB-supplies-via-regulator-ucl.patch b/package/boot/uboot-d1/patches/0009-phy-sun4i-usb-Control-USB-supplies-via-regulator-ucl.patch new file mode 100644 index 00000000000000..bbbfd58617429e --- /dev/null +++ b/package/boot/uboot-d1/patches/0009-phy-sun4i-usb-Control-USB-supplies-via-regulator-ucl.patch @@ -0,0 +1,162 @@ +From e8fb34342dfb79cd2059431dd1a0f03202a244ca Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 22:11:37 -0500 +Subject: [PATCH 09/90] phy: sun4i-usb: Control USB supplies via regulator + uclass + +The device tree binding for the PHY provides VBUS supplies as regulator +references. Now that all boards have the appropriate regulator uclass +drivers enabled, the PHY driver can switch to using them. This replaces +direct GPIO usage, which in some cases needed a special DM-incompatible +"virtual" GPIO from the PMIC. + +The following boards provided a value for CONFIG_USB0_VBUS_PIN, but are +missing the "usb0_vbus-supply" property in their device tree. None of +them have the MUSB controller enabled in host or OTG mode, so they +should see no impact: + - Ainol_AW1_defconfig / sun7i-a20-ainol-aw1 + - Ampe_A76_defconfig / sun5i-a13-ampe-a76 + - CHIP_pro_defconfig / sun5i-gr8-chip-pro + - Cubieboard4_defconfig / sun9i-a80-cubieboard4 + - Merrii_A80_Optimus_defconfig / sun9i-a80-optimus + - Sunchip_CX-A99_defconfig / sun9i-a80-cx-a99 + - Yones_Toptech_BD1078_defconfig / sun7i-a20-yones-toptech-bd1078 + - Yones_Toptech_BS1078_V2_defconfig / + sun6i-a31s-yones-toptech-bs1078-v2 + - iNet_3F_defconfig / sun4i-a10-inet-3f + - iNet_3W_defconfig / sun4i-a10-inet-3w + - iNet_86VS_defconfig / sun5i-a13-inet-86vs + - iNet_D978_rev2_defconfig / sun8i-a33-inet-d978-rev2 + - icnova-a20-swac_defconfig / sun7i-a20-icnova-swac + - sun8i_a23_evb_defconfig / sun8i-a23-evb + +Similarly, the following boards set CONFIG_USB1_VBUS_PIN, but do not +have "usb1_vbus-supply" in their device tree. Neither of them have USB +enabled at all, so again there should be no impact: + - Cubieboard4_defconfig / sun9i-a80-cubieboard4 (also for USB3) + - sun8i_a23_evb_defconfig / sun8i-a23-evb + +The following boards use a different pin for USB1 VBUS between their +defconfig and their device tree. Depending on which is correct, they +may be broken: + - Linksprite_pcDuino3_Nano_defconfig (PH11) / + sun7i-a20-pcduino3-nano (PD2) + - icnova-a20-swac_defconfig (PG10) / sun7i-a20-icnova-swac (PH6) + +Finally, this board has conflicting pins given for its USB2 VBUS: + - Lamobo_R1_defconfig (PH3) / sun7i-a20-lamobo-r1 (PH12) + +Signed-off-by: Samuel Holland +--- + drivers/phy/allwinner/phy-sun4i-usb.c | 41 +++++++++++++-------------- + 1 file changed, 19 insertions(+), 22 deletions(-) + +--- a/drivers/phy/allwinner/phy-sun4i-usb.c ++++ b/drivers/phy/allwinner/phy-sun4i-usb.c +@@ -97,27 +97,22 @@ struct sun4i_usb_phy_cfg { + }; + + struct sun4i_usb_phy_info { +- const char *gpio_vbus; + const char *gpio_vbus_det; + const char *gpio_id_det; + } phy_info[] = { + { +- .gpio_vbus = CONFIG_USB0_VBUS_PIN, + .gpio_vbus_det = CONFIG_USB0_VBUS_DET, + .gpio_id_det = CONFIG_USB0_ID_DET, + }, + { +- .gpio_vbus = CONFIG_USB1_VBUS_PIN, + .gpio_vbus_det = NULL, + .gpio_id_det = NULL, + }, + { +- .gpio_vbus = CONFIG_USB2_VBUS_PIN, + .gpio_vbus_det = NULL, + .gpio_id_det = NULL, + }, + { +- .gpio_vbus = CONFIG_USB3_VBUS_PIN, + .gpio_vbus_det = NULL, + .gpio_id_det = NULL, + }, +@@ -125,11 +120,11 @@ struct sun4i_usb_phy_info { + + struct sun4i_usb_phy_plat { + void __iomem *pmu; +- struct gpio_desc gpio_vbus; + struct gpio_desc gpio_vbus_det; + struct gpio_desc gpio_id_det; + struct clk clocks; + struct reset_ctl resets; ++ struct udevice *vbus; + int id; + }; + +@@ -218,14 +213,18 @@ static int sun4i_usb_phy_power_on(struct + { + struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev); + struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id]; ++ int ret; + + if (initial_usb_scan_delay) { + mdelay(initial_usb_scan_delay); + initial_usb_scan_delay = 0; + } + +- if (dm_gpio_is_valid(&usb_phy->gpio_vbus)) +- dm_gpio_set_value(&usb_phy->gpio_vbus, 1); ++ if (usb_phy->vbus) { ++ ret = regulator_set_enable(usb_phy->vbus, true); ++ if (ret && ret != -ENOSYS) ++ return ret; ++ } + + return 0; + } +@@ -234,9 +233,13 @@ static int sun4i_usb_phy_power_off(struc + { + struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev); + struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id]; ++ int ret; + +- if (dm_gpio_is_valid(&usb_phy->gpio_vbus)) +- dm_gpio_set_value(&usb_phy->gpio_vbus, 0); ++ if (usb_phy->vbus) { ++ ret = regulator_set_enable(usb_phy->vbus, false); ++ if (ret && ret != -ENOSYS) ++ return ret; ++ } + + return 0; + } +@@ -450,22 +453,16 @@ static int sun4i_usb_phy_probe(struct ud + for (i = 0; i < data->cfg->num_phys; i++) { + struct sun4i_usb_phy_plat *phy = &plat[i]; + struct sun4i_usb_phy_info *info = &phy_info[i]; +- char name[16]; ++ char name[20]; + + if (data->cfg->missing_phys & BIT(i)) + continue; + +- ret = dm_gpio_lookup_name(info->gpio_vbus, &phy->gpio_vbus); +- if (ret == 0) { +- ret = dm_gpio_request(&phy->gpio_vbus, "usb_vbus"); +- if (ret) +- return ret; +- ret = dm_gpio_set_dir_flags(&phy->gpio_vbus, +- GPIOD_IS_OUT); +- if (ret) +- return ret; +- ret = dm_gpio_set_value(&phy->gpio_vbus, 0); +- if (ret) ++ snprintf(name, sizeof(name), "usb%d_vbus-supply", i); ++ ret = device_get_supply_regulator(dev, name, &phy->vbus); ++ if (phy->vbus) { ++ ret = regulator_set_enable(phy->vbus, false); ++ if (ret && ret != -ENOSYS) + return ret; + } + diff --git a/package/boot/uboot-d1/patches/0010-sunxi-Remove-obsolete-USBx_VBUS_PIN-Kconfig-symbols.patch b/package/boot/uboot-d1/patches/0010-sunxi-Remove-obsolete-USBx_VBUS_PIN-Kconfig-symbols.patch new file mode 100644 index 00000000000000..edeae405eaf0aa --- /dev/null +++ b/package/boot/uboot-d1/patches/0010-sunxi-Remove-obsolete-USBx_VBUS_PIN-Kconfig-symbols.patch @@ -0,0 +1,58 @@ +From 649bb7845e30805c66f62fc5725c4dbf350f21cb Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 22:26:40 -0500 +Subject: [PATCH 10/90] sunxi: Remove obsolete USBx_VBUS_PIN Kconfig symbols + +Now that the USB PHY driver uses the device tree to get VBUS supply +regulators, these Kconfig symbols are unused. Remove them. + +Signed-off-by: Samuel Holland +--- + arch/arm/mach-sunxi/Kconfig | 29 ----------------------------- + 1 file changed, 29 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -693,13 +693,6 @@ config MMC_SUNXI_SLOT_EXTRA + slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable + support for this. + +-config USB0_VBUS_PIN +- string "Vbus enable pin for usb0 (otg)" +- default "" +- ---help--- +- Set the Vbus enable pin for usb0 (otg). This takes a string in the +- format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. +- + config USB0_VBUS_DET + string "Vbus detect pin for usb0 (otg)" + default "" +@@ -714,28 +707,6 @@ config USB0_ID_DET + Set the ID detect pin for usb0 (otg). This takes a string in the + format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + +-config USB1_VBUS_PIN +- string "Vbus enable pin for usb1 (ehci0)" +- default "PH6" if MACH_SUN4I || MACH_SUN7I +- default "PH27" if MACH_SUN6I +- ---help--- +- Set the Vbus enable pin for usb1 (ehci0, usb0 is the otg). This takes +- a string in the format understood by sunxi_name_to_gpio, e.g. +- PH1 for pin 1 of port H. +- +-config USB2_VBUS_PIN +- string "Vbus enable pin for usb2 (ehci1)" +- default "PH3" if MACH_SUN4I || MACH_SUN7I +- default "PH24" if MACH_SUN6I +- ---help--- +- See USB1_VBUS_PIN help text. +- +-config USB3_VBUS_PIN +- string "Vbus enable pin for usb3 (ehci2)" +- default "" +- ---help--- +- See USB1_VBUS_PIN help text. +- + config I2C0_ENABLE + bool "Enable I2C/TWI controller 0" + default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I_R40 diff --git a/package/boot/uboot-d1/patches/0011-clk-sunxi-Add-support-for-the-D1-CCU.patch b/package/boot/uboot-d1/patches/0011-clk-sunxi-Add-support-for-the-D1-CCU.patch new file mode 100644 index 00000000000000..faa7f64327ba26 --- /dev/null +++ b/package/boot/uboot-d1/patches/0011-clk-sunxi-Add-support-for-the-D1-CCU.patch @@ -0,0 +1,393 @@ +From 73d6c82e34e89cfde880d1948b3e0dc714adead8 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 30 Apr 2022 22:34:19 -0500 +Subject: [PATCH 11/90] clk: sunxi: Add support for the D1 CCU + +Since the D1 CCU binding is defined, we can add support for its +gates/resets, following the pattern of the existing drivers. + +Series-to: sunxi + +Signed-off-by: Samuel Holland +--- + drivers/clk/sunxi/Kconfig | 6 + + drivers/clk/sunxi/Makefile | 1 + + drivers/clk/sunxi/clk_d1.c | 82 ++++++++++++ + drivers/clk/sunxi/clk_sunxi.c | 5 + + include/dt-bindings/clock/sun20i-d1-ccu.h | 156 ++++++++++++++++++++++ + include/dt-bindings/reset/sun20i-d1-ccu.h | 77 +++++++++++ + 6 files changed, 327 insertions(+) + create mode 100644 drivers/clk/sunxi/clk_d1.c + create mode 100644 include/dt-bindings/clock/sun20i-d1-ccu.h + create mode 100644 include/dt-bindings/reset/sun20i-d1-ccu.h + +--- a/drivers/clk/sunxi/Kconfig ++++ b/drivers/clk/sunxi/Kconfig +@@ -87,6 +87,12 @@ config CLK_SUN8I_H3 + This enables common clock driver support for platforms based + on Allwinner H3/H5 SoC. + ++config CLK_SUN20I_D1 ++ bool "Clock driver for Allwinner D1" ++ help ++ This enables common clock driver support for platforms based ++ on Allwinner D1 SoC. ++ + config CLK_SUN50I_H6 + bool "Clock driver for Allwinner H6" + default MACH_SUN50I_H6 +--- a/drivers/clk/sunxi/Makefile ++++ b/drivers/clk/sunxi/Makefile +@@ -19,6 +19,7 @@ obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o + obj-$(CONFIG_CLK_SUN8I_V3S) += clk_v3s.o + obj-$(CONFIG_CLK_SUN9I_A80) += clk_a80.o + obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o ++obj-$(CONFIG_CLK_SUN20I_D1) += clk_d1.o + obj-$(CONFIG_CLK_SUN50I_H6) += clk_h6.o + obj-$(CONFIG_CLK_SUN50I_H6_R) += clk_h6_r.o + obj-$(CONFIG_CLK_SUN50I_H616) += clk_h616.o +--- /dev/null ++++ b/drivers/clk/sunxi/clk_d1.c +@@ -0,0 +1,82 @@ ++// SPDX-License-Identifier: (GPL-2.0+ OR MIT) ++/* ++ * Copyright (C) 2021 Samuel Holland ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++static struct ccu_clk_gate d1_gates[] = { ++ [CLK_BUS_MMC0] = GATE(0x84c, BIT(0)), ++ [CLK_BUS_MMC1] = GATE(0x84c, BIT(1)), ++ [CLK_BUS_MMC2] = GATE(0x84c, BIT(2)), ++ [CLK_BUS_UART0] = GATE(0x90c, BIT(0)), ++ [CLK_BUS_UART1] = GATE(0x90c, BIT(1)), ++ [CLK_BUS_UART2] = GATE(0x90c, BIT(2)), ++ [CLK_BUS_UART3] = GATE(0x90c, BIT(3)), ++ [CLK_BUS_UART4] = GATE(0x90c, BIT(4)), ++ [CLK_BUS_UART5] = GATE(0x90c, BIT(5)), ++ [CLK_BUS_I2C0] = GATE(0x91c, BIT(0)), ++ [CLK_BUS_I2C1] = GATE(0x91c, BIT(1)), ++ [CLK_BUS_I2C2] = GATE(0x91c, BIT(2)), ++ [CLK_BUS_I2C3] = GATE(0x91c, BIT(3)), ++ [CLK_SPI0] = GATE(0x940, BIT(31)), ++ [CLK_SPI1] = GATE(0x944, BIT(31)), ++ [CLK_BUS_SPI0] = GATE(0x96c, BIT(0)), ++ [CLK_BUS_SPI1] = GATE(0x96c, BIT(1)), ++ ++ [CLK_BUS_EMAC] = GATE(0x97c, BIT(0)), ++ ++ [CLK_USB_OHCI0] = GATE(0xa70, BIT(31)), ++ [CLK_USB_OHCI1] = GATE(0xa74, BIT(31)), ++ [CLK_BUS_OHCI0] = GATE(0xa8c, BIT(0)), ++ [CLK_BUS_OHCI1] = GATE(0xa8c, BIT(1)), ++ [CLK_BUS_EHCI0] = GATE(0xa8c, BIT(4)), ++ [CLK_BUS_EHCI1] = GATE(0xa8c, BIT(5)), ++ [CLK_BUS_OTG] = GATE(0xa8c, BIT(8)), ++ [CLK_BUS_LRADC] = GATE(0xa9c, BIT(0)), ++ ++ [CLK_RISCV] = GATE(0xd04, BIT(31)), ++}; ++ ++static struct ccu_reset d1_resets[] = { ++ [RST_BUS_MMC0] = RESET(0x84c, BIT(16)), ++ [RST_BUS_MMC1] = RESET(0x84c, BIT(17)), ++ [RST_BUS_MMC2] = RESET(0x84c, BIT(18)), ++ [RST_BUS_UART0] = RESET(0x90c, BIT(16)), ++ [RST_BUS_UART1] = RESET(0x90c, BIT(17)), ++ [RST_BUS_UART2] = RESET(0x90c, BIT(18)), ++ [RST_BUS_UART3] = RESET(0x90c, BIT(19)), ++ [RST_BUS_UART4] = RESET(0x90c, BIT(20)), ++ [RST_BUS_UART5] = RESET(0x90c, BIT(21)), ++ [RST_BUS_I2C0] = RESET(0x91c, BIT(16)), ++ [RST_BUS_I2C1] = RESET(0x91c, BIT(17)), ++ [RST_BUS_I2C2] = RESET(0x91c, BIT(18)), ++ [RST_BUS_I2C3] = RESET(0x91c, BIT(19)), ++ [RST_BUS_SPI0] = RESET(0x96c, BIT(16)), ++ [RST_BUS_SPI1] = RESET(0x96c, BIT(17)), ++ ++ [RST_BUS_EMAC] = RESET(0x97c, BIT(16)), ++ ++ [RST_USB_PHY0] = RESET(0xa70, BIT(30)), ++ [RST_USB_PHY1] = RESET(0xa74, BIT(30)), ++ [RST_BUS_OHCI0] = RESET(0xa8c, BIT(16)), ++ [RST_BUS_OHCI1] = RESET(0xa8c, BIT(17)), ++ [RST_BUS_EHCI0] = RESET(0xa8c, BIT(20)), ++ [RST_BUS_EHCI1] = RESET(0xa8c, BIT(21)), ++ [RST_BUS_OTG] = RESET(0xa8c, BIT(24)), ++ [RST_BUS_LRADC] = RESET(0xa9c, BIT(16)), ++}; ++ ++const struct ccu_desc d1_ccu_desc = { ++ .gates = d1_gates, ++ .resets = d1_resets, ++ .num_gates = ARRAY_SIZE(d1_gates), ++ .num_resets = ARRAY_SIZE(d1_resets), ++}; +--- a/drivers/clk/sunxi/clk_sunxi.c ++++ b/drivers/clk/sunxi/clk_sunxi.c +@@ -118,6 +118,7 @@ extern const struct ccu_desc a64_ccu_des + extern const struct ccu_desc a80_ccu_desc; + extern const struct ccu_desc a80_mmc_clk_desc; + extern const struct ccu_desc a83t_ccu_desc; ++extern const struct ccu_desc d1_ccu_desc; + extern const struct ccu_desc f1c100s_ccu_desc; + extern const struct ccu_desc h3_ccu_desc; + extern const struct ccu_desc h6_ccu_desc; +@@ -183,6 +184,10 @@ static const struct udevice_id sunxi_clk + { .compatible = "allwinner,sun9i-a80-mmc-config-clk", + .data = (ulong)&a80_mmc_clk_desc }, + #endif ++#ifdef CONFIG_CLK_SUN20I_D1 ++ { .compatible = "allwinner,sun20i-d1-ccu", ++ .data = (ulong)&d1_ccu_desc }, ++#endif + #ifdef CONFIG_CLK_SUN50I_A64 + { .compatible = "allwinner,sun50i-a64-ccu", + .data = (ulong)&a64_ccu_desc }, +--- /dev/null ++++ b/include/dt-bindings/clock/sun20i-d1-ccu.h +@@ -0,0 +1,156 @@ ++/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */ ++/* ++ * Copyright (C) 2020 huangzhenwei@allwinnertech.com ++ * Copyright (C) 2021 Samuel Holland ++ */ ++ ++#ifndef _DT_BINDINGS_CLK_SUN20I_D1_CCU_H_ ++#define _DT_BINDINGS_CLK_SUN20I_D1_CCU_H_ ++ ++#define CLK_PLL_CPUX 0 ++#define CLK_PLL_DDR0 1 ++#define CLK_PLL_PERIPH0_4X 2 ++#define CLK_PLL_PERIPH0_2X 3 ++#define CLK_PLL_PERIPH0_800M 4 ++#define CLK_PLL_PERIPH0 5 ++#define CLK_PLL_PERIPH0_DIV3 6 ++#define CLK_PLL_VIDEO0_4X 7 ++#define CLK_PLL_VIDEO0_2X 8 ++#define CLK_PLL_VIDEO0 9 ++#define CLK_PLL_VIDEO1_4X 10 ++#define CLK_PLL_VIDEO1_2X 11 ++#define CLK_PLL_VIDEO1 12 ++#define CLK_PLL_VE 13 ++#define CLK_PLL_AUDIO0_4X 14 ++#define CLK_PLL_AUDIO0_2X 15 ++#define CLK_PLL_AUDIO0 16 ++#define CLK_PLL_AUDIO1 17 ++#define CLK_PLL_AUDIO1_DIV2 18 ++#define CLK_PLL_AUDIO1_DIV5 19 ++#define CLK_CPUX 20 ++#define CLK_CPUX_AXI 21 ++#define CLK_CPUX_APB 22 ++#define CLK_PSI_AHB 23 ++#define CLK_APB0 24 ++#define CLK_APB1 25 ++#define CLK_MBUS 26 ++#define CLK_DE 27 ++#define CLK_BUS_DE 28 ++#define CLK_DI 29 ++#define CLK_BUS_DI 30 ++#define CLK_G2D 31 ++#define CLK_BUS_G2D 32 ++#define CLK_CE 33 ++#define CLK_BUS_CE 34 ++#define CLK_VE 35 ++#define CLK_BUS_VE 36 ++#define CLK_BUS_DMA 37 ++#define CLK_BUS_MSGBOX0 38 ++#define CLK_BUS_MSGBOX1 39 ++#define CLK_BUS_MSGBOX2 40 ++#define CLK_BUS_SPINLOCK 41 ++#define CLK_BUS_HSTIMER 42 ++#define CLK_AVS 43 ++#define CLK_BUS_DBG 44 ++#define CLK_BUS_PWM 45 ++#define CLK_BUS_IOMMU 46 ++#define CLK_DRAM 47 ++#define CLK_MBUS_DMA 48 ++#define CLK_MBUS_VE 49 ++#define CLK_MBUS_CE 50 ++#define CLK_MBUS_TVIN 51 ++#define CLK_MBUS_CSI 52 ++#define CLK_MBUS_G2D 53 ++#define CLK_MBUS_RISCV 54 ++#define CLK_BUS_DRAM 55 ++#define CLK_MMC0 56 ++#define CLK_MMC1 57 ++#define CLK_MMC2 58 ++#define CLK_BUS_MMC0 59 ++#define CLK_BUS_MMC1 60 ++#define CLK_BUS_MMC2 61 ++#define CLK_BUS_UART0 62 ++#define CLK_BUS_UART1 63 ++#define CLK_BUS_UART2 64 ++#define CLK_BUS_UART3 65 ++#define CLK_BUS_UART4 66 ++#define CLK_BUS_UART5 67 ++#define CLK_BUS_I2C0 68 ++#define CLK_BUS_I2C1 69 ++#define CLK_BUS_I2C2 70 ++#define CLK_BUS_I2C3 71 ++#define CLK_SPI0 72 ++#define CLK_SPI1 73 ++#define CLK_BUS_SPI0 74 ++#define CLK_BUS_SPI1 75 ++#define CLK_EMAC_25M 76 ++#define CLK_BUS_EMAC 77 ++#define CLK_IR_TX 78 ++#define CLK_BUS_IR_TX 79 ++#define CLK_BUS_GPADC 80 ++#define CLK_BUS_THS 81 ++#define CLK_I2S0 82 ++#define CLK_I2S1 83 ++#define CLK_I2S2 84 ++#define CLK_I2S2_ASRC 85 ++#define CLK_BUS_I2S0 86 ++#define CLK_BUS_I2S1 87 ++#define CLK_BUS_I2S2 88 ++#define CLK_SPDIF_TX 89 ++#define CLK_SPDIF_RX 90 ++#define CLK_BUS_SPDIF 91 ++#define CLK_DMIC 92 ++#define CLK_BUS_DMIC 93 ++#define CLK_AUDIO_DAC 94 ++#define CLK_AUDIO_ADC 95 ++#define CLK_BUS_AUDIO 96 ++#define CLK_USB_OHCI0 97 ++#define CLK_USB_OHCI1 98 ++#define CLK_BUS_OHCI0 99 ++#define CLK_BUS_OHCI1 100 ++#define CLK_BUS_EHCI0 101 ++#define CLK_BUS_EHCI1 102 ++#define CLK_BUS_OTG 103 ++#define CLK_BUS_LRADC 104 ++#define CLK_BUS_DPSS_TOP 105 ++#define CLK_HDMI_24M 106 ++#define CLK_HDMI_CEC_32K 107 ++#define CLK_HDMI_CEC 108 ++#define CLK_BUS_HDMI 109 ++#define CLK_MIPI_DSI 110 ++#define CLK_BUS_MIPI_DSI 111 ++#define CLK_TCON_LCD0 112 ++#define CLK_BUS_TCON_LCD0 113 ++#define CLK_TCON_TV 114 ++#define CLK_BUS_TCON_TV 115 ++#define CLK_TVE 116 ++#define CLK_BUS_TVE_TOP 117 ++#define CLK_BUS_TVE 118 ++#define CLK_TVD 119 ++#define CLK_BUS_TVD_TOP 120 ++#define CLK_BUS_TVD 121 ++#define CLK_LEDC 122 ++#define CLK_BUS_LEDC 123 ++#define CLK_CSI_TOP 124 ++#define CLK_CSI_MCLK 125 ++#define CLK_BUS_CSI 126 ++#define CLK_TPADC 127 ++#define CLK_BUS_TPADC 128 ++#define CLK_BUS_TZMA 129 ++#define CLK_DSP 130 ++#define CLK_BUS_DSP_CFG 131 ++#define CLK_RISCV 132 ++#define CLK_RISCV_AXI 133 ++#define CLK_BUS_RISCV_CFG 134 ++#define CLK_FANOUT_24M 135 ++#define CLK_FANOUT_12M 136 ++#define CLK_FANOUT_16M 137 ++#define CLK_FANOUT_25M 138 ++#define CLK_FANOUT_32K 139 ++#define CLK_FANOUT_27M 140 ++#define CLK_FANOUT_PCLK 141 ++#define CLK_FANOUT0 142 ++#define CLK_FANOUT1 143 ++#define CLK_FANOUT2 144 ++ ++#endif /* _DT_BINDINGS_CLK_SUN20I_D1_CCU_H_ */ +--- /dev/null ++++ b/include/dt-bindings/reset/sun20i-d1-ccu.h +@@ -0,0 +1,77 @@ ++/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */ ++/* ++ * Copyright (c) 2020 huangzhenwei@allwinnertech.com ++ * Copyright (C) 2021 Samuel Holland ++ */ ++ ++#ifndef _DT_BINDINGS_RST_SUN20I_D1_CCU_H_ ++#define _DT_BINDINGS_RST_SUN20I_D1_CCU_H_ ++ ++#define RST_MBUS 0 ++#define RST_BUS_DE 1 ++#define RST_BUS_DI 2 ++#define RST_BUS_G2D 3 ++#define RST_BUS_CE 4 ++#define RST_BUS_VE 5 ++#define RST_BUS_DMA 6 ++#define RST_BUS_MSGBOX0 7 ++#define RST_BUS_MSGBOX1 8 ++#define RST_BUS_MSGBOX2 9 ++#define RST_BUS_SPINLOCK 10 ++#define RST_BUS_HSTIMER 11 ++#define RST_BUS_DBG 12 ++#define RST_BUS_PWM 13 ++#define RST_BUS_DRAM 14 ++#define RST_BUS_MMC0 15 ++#define RST_BUS_MMC1 16 ++#define RST_BUS_MMC2 17 ++#define RST_BUS_UART0 18 ++#define RST_BUS_UART1 19 ++#define RST_BUS_UART2 20 ++#define RST_BUS_UART3 21 ++#define RST_BUS_UART4 22 ++#define RST_BUS_UART5 23 ++#define RST_BUS_I2C0 24 ++#define RST_BUS_I2C1 25 ++#define RST_BUS_I2C2 26 ++#define RST_BUS_I2C3 27 ++#define RST_BUS_SPI0 28 ++#define RST_BUS_SPI1 29 ++#define RST_BUS_EMAC 30 ++#define RST_BUS_IR_TX 31 ++#define RST_BUS_GPADC 32 ++#define RST_BUS_THS 33 ++#define RST_BUS_I2S0 34 ++#define RST_BUS_I2S1 35 ++#define RST_BUS_I2S2 36 ++#define RST_BUS_SPDIF 37 ++#define RST_BUS_DMIC 38 ++#define RST_BUS_AUDIO 39 ++#define RST_USB_PHY0 40 ++#define RST_USB_PHY1 41 ++#define RST_BUS_OHCI0 42 ++#define RST_BUS_OHCI1 43 ++#define RST_BUS_EHCI0 44 ++#define RST_BUS_EHCI1 45 ++#define RST_BUS_OTG 46 ++#define RST_BUS_LRADC 47 ++#define RST_BUS_DPSS_TOP 48 ++#define RST_BUS_HDMI_SUB 49 ++#define RST_BUS_HDMI_MAIN 50 ++#define RST_BUS_MIPI_DSI 51 ++#define RST_BUS_TCON_LCD0 52 ++#define RST_BUS_TCON_TV 53 ++#define RST_BUS_LVDS0 54 ++#define RST_BUS_TVE 55 ++#define RST_BUS_TVE_TOP 56 ++#define RST_BUS_TVD 57 ++#define RST_BUS_TVD_TOP 58 ++#define RST_BUS_LEDC 59 ++#define RST_BUS_CSI 60 ++#define RST_BUS_TPADC 61 ++#define RST_DSP 62 ++#define RST_BUS_DSP_CFG 63 ++#define RST_BUS_DSP_DBG 64 ++#define RST_BUS_RISCV_CFG 65 ++ ++#endif /* _DT_BINDINGS_RST_SUN20I_D1_CCU_H_ */ diff --git a/package/boot/uboot-d1/patches/0012-gpio-axp-Remove-virtual-VBUS-enable-GPIO.patch b/package/boot/uboot-d1/patches/0012-gpio-axp-Remove-virtual-VBUS-enable-GPIO.patch new file mode 100644 index 00000000000000..53f893c0ff7b73 --- /dev/null +++ b/package/boot/uboot-d1/patches/0012-gpio-axp-Remove-virtual-VBUS-enable-GPIO.patch @@ -0,0 +1,227 @@ +From cbb281e0ec847b9de41970e470348b3534bb9a9f Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 26 Aug 2021 18:02:54 -0500 +Subject: [PATCH 12/90] gpio: axp: Remove virtual VBUS enable GPIO + +Now that this functionality is modeled using the device tree and +regulator uclass, the named GPIO is not referenced anywhere. Remove +it, along with the rest of the support for AXP virtual GPIOs. + +Signed-off-by: Samuel Holland +--- + arch/arm/include/asm/arch-sunxi/gpio.h | 8 --- + drivers/gpio/axp_gpio.c | 75 ++++++++------------------ + drivers/gpio/sunxi_gpio.c | 8 --- + include/axp221.h | 4 -- + include/axp809.h | 4 -- + include/axp818.h | 4 -- + 6 files changed, 21 insertions(+), 82 deletions(-) + +--- a/arch/arm/include/asm/arch-sunxi/gpio.h ++++ b/arch/arm/include/asm/arch-sunxi/gpio.h +@@ -111,7 +111,6 @@ enum sunxi_gpio_number { + SUNXI_GPIO_L_START = 352, + SUNXI_GPIO_M_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_L), + SUNXI_GPIO_N_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_M), +- SUNXI_GPIO_AXP0_START = 1024, + }; + + /* SUNXI GPIO number definitions */ +@@ -128,8 +127,6 @@ enum sunxi_gpio_number { + #define SUNXI_GPM(_nr) (SUNXI_GPIO_M_START + (_nr)) + #define SUNXI_GPN(_nr) (SUNXI_GPIO_N_START + (_nr)) + +-#define SUNXI_GPAXP0(_nr) (SUNXI_GPIO_AXP0_START + (_nr)) +- + /* GPIO pin function config */ + #define SUNXI_GPIO_INPUT 0 + #define SUNXI_GPIO_OUTPUT 1 +@@ -207,11 +204,6 @@ enum sunxi_gpio_number { + #define SUNXI_GPIO_PULL_UP 1 + #define SUNXI_GPIO_PULL_DOWN 2 + +-/* Virtual AXP0 GPIOs */ +-#define SUNXI_GPIO_AXP0_PREFIX "AXP0-" +-#define SUNXI_GPIO_AXP0_VBUS_ENABLE 5 +-#define SUNXI_GPIO_AXP0_GPIO_COUNT 6 +- + struct sunxi_gpio_plat { + struct sunxi_gpio *regs; + char bank_name[3]; +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -15,6 +15,9 @@ + #include + #include + ++#define AXP_GPIO_PREFIX "AXP0-" ++#define AXP_GPIO_COUNT 4 ++ + static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val); + + static u8 axp_get_gpio_ctrl_reg(unsigned pin) +@@ -46,28 +49,14 @@ static int axp_gpio_direction_input(stru + static int axp_gpio_direction_output(struct udevice *dev, unsigned pin, + int val) + { +- __maybe_unused int ret; + u8 reg; + +- switch (pin) { +-#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC +- /* Only available on later PMICs */ +- case SUNXI_GPIO_AXP0_VBUS_ENABLE: +- ret = pmic_bus_clrbits(AXP_MISC_CTRL, +- AXP_MISC_CTRL_N_VBUSEN_FUNC); +- if (ret) +- return ret; +- +- return axp_gpio_set_value(dev, pin, val); +-#endif +- default: +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; ++ reg = axp_get_gpio_ctrl_reg(pin); ++ if (reg == 0) ++ return -EINVAL; + +- return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); +- } ++ return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : ++ AXP_GPIO_CTRL_OUTPUT_LOW); + } + + static int axp_gpio_get_value(struct udevice *dev, unsigned pin) +@@ -75,25 +64,16 @@ static int axp_gpio_get_value(struct ude + u8 reg, val, mask; + int ret; + +- switch (pin) { +-#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC +- /* Only available on later PMICs */ +- case SUNXI_GPIO_AXP0_VBUS_ENABLE: +- ret = pmic_bus_read(AXP_VBUS_IPSOUT, &val); +- mask = AXP_VBUS_IPSOUT_DRIVEBUS; +- break; +-#endif +- default: +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; ++ reg = axp_get_gpio_ctrl_reg(pin); ++ if (reg == 0) ++ return -EINVAL; + +- ret = pmic_bus_read(AXP_GPIO_STATE, &val); +- mask = 1 << (pin + AXP_GPIO_STATE_OFFSET); +- } ++ ret = pmic_bus_read(AXP_GPIO_STATE, &val); + if (ret) + return ret; + ++ mask = 1 << (pin + AXP_GPIO_STATE_OFFSET); ++ + return (val & mask) ? 1 : 0; + } + +@@ -101,25 +81,12 @@ static int axp_gpio_set_value(struct ude + { + u8 reg; + +- switch (pin) { +-#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC +- /* Only available on later PMICs */ +- case SUNXI_GPIO_AXP0_VBUS_ENABLE: +- if (val) +- return pmic_bus_setbits(AXP_VBUS_IPSOUT, +- AXP_VBUS_IPSOUT_DRIVEBUS); +- else +- return pmic_bus_clrbits(AXP_VBUS_IPSOUT, +- AXP_VBUS_IPSOUT_DRIVEBUS); +-#endif +- default: +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; ++ reg = axp_get_gpio_ctrl_reg(pin); ++ if (reg == 0) ++ return -EINVAL; + +- return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); +- } ++ return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : ++ AXP_GPIO_CTRL_OUTPUT_LOW); + } + + static const struct dm_gpio_ops gpio_axp_ops = { +@@ -134,8 +101,8 @@ static int gpio_axp_probe(struct udevice + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + + /* Tell the uclass how many GPIOs we have */ +- uc_priv->bank_name = strdup(SUNXI_GPIO_AXP0_PREFIX); +- uc_priv->gpio_count = SUNXI_GPIO_AXP0_GPIO_COUNT; ++ uc_priv->bank_name = AXP_GPIO_PREFIX; ++ uc_priv->gpio_count = AXP_GPIO_COUNT; + + return 0; + } +--- a/drivers/gpio/sunxi_gpio.c ++++ b/drivers/gpio/sunxi_gpio.c +@@ -114,15 +114,7 @@ int sunxi_name_to_gpio(const char *name) + { + unsigned int gpio; + int ret; +-#if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO +- char lookup[8]; + +- if (strcasecmp(name, "AXP0-VBUS-ENABLE") == 0) { +- sprintf(lookup, SUNXI_GPIO_AXP0_PREFIX "%d", +- SUNXI_GPIO_AXP0_VBUS_ENABLE); +- name = lookup; +- } +-#endif + ret = gpio_lookup_name(name, NULL, NULL, &gpio); + + return ret ? ret : gpio; +--- a/include/axp221.h ++++ b/include/axp221.h +@@ -53,10 +53,6 @@ + #ifdef CONFIG_AXP221_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_VBUS_IPSOUT 0x30 +-#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) +-#define AXP_MISC_CTRL 0x8f +-#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4) + #define AXP_GPIO0_CTRL 0x90 + #define AXP_GPIO1_CTRL 0x92 + #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +--- a/include/axp809.h ++++ b/include/axp809.h +@@ -47,10 +47,6 @@ + #ifdef CONFIG_AXP809_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_VBUS_IPSOUT 0x30 +-#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) +-#define AXP_MISC_CTRL 0x8f +-#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4) + #define AXP_GPIO0_CTRL 0x90 + #define AXP_GPIO1_CTRL 0x92 + #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +--- a/include/axp818.h ++++ b/include/axp818.h +@@ -61,10 +61,6 @@ + #ifdef CONFIG_AXP818_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_VBUS_IPSOUT 0x30 +-#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2) +-#define AXP_MISC_CTRL 0x8f +-#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4) + #define AXP_GPIO0_CTRL 0x90 + #define AXP_GPIO1_CTRL 0x92 + #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ diff --git a/package/boot/uboot-d1/patches/0013-clk-sunxi-Add-a-driver-for-the-legacy-A31-A23-A33-PR.patch b/package/boot/uboot-d1/patches/0013-clk-sunxi-Add-a-driver-for-the-legacy-A31-A23-A33-PR.patch new file mode 100644 index 00000000000000..2c0029a29b8b37 --- /dev/null +++ b/package/boot/uboot-d1/patches/0013-clk-sunxi-Add-a-driver-for-the-legacy-A31-A23-A33-PR.patch @@ -0,0 +1,160 @@ +From 5a909f4d4d10f3a7a59b3b75eee502937e166891 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 2 May 2022 22:00:05 -0500 +Subject: [PATCH 13/90] clk: sunxi: Add a driver for the legacy A31/A23/A33 + PRCM + +Signed-off-by: Samuel Holland +--- + drivers/clk/sunxi/Kconfig | 13 ++++- + drivers/clk/sunxi/Makefile | 1 + + drivers/clk/sunxi/clk_a31_apb0.c | 97 ++++++++++++++++++++++++++++++++ + include/clk/sunxi.h | 1 + + 4 files changed, 110 insertions(+), 2 deletions(-) + create mode 100644 drivers/clk/sunxi/clk_a31_apb0.c + +--- a/drivers/clk/sunxi/Kconfig ++++ b/drivers/clk/sunxi/Kconfig +@@ -38,12 +38,21 @@ config CLK_SUN6I_A31 + This enables common clock driver support for platforms based + on Allwinner A31/A31s SoC. + ++config CLK_SUN6I_A31_APB0 ++ bool "Clock driver for Allwinner A31 generation PRCM (legacy)" ++ default MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 ++ help ++ This enables common clock driver support for the PRCM ++ in Allwinner A31/A31s/A23/A33 SoCs using the legacy PRCM ++ MFD binding. ++ + config CLK_SUN6I_A31_R +- bool "Clock driver for Allwinner A31 generation PRCM" ++ bool "Clock driver for Allwinner A31 generation PRCM (CCU)" + default SUNXI_GEN_SUN6I + help + This enables common clock driver support for the PRCM +- in Allwinner A31/A31s/A23/A33/A83T/H3/A64/H5 SoCs. ++ in Allwinner A31/A31s/A23/A33/A83T/H3/A64/H5 SoCs using ++ the new CCU binding. + + config CLK_SUN8I_A23 + bool "Clock driver for Allwinner A23/A33" +--- a/drivers/clk/sunxi/Makefile ++++ b/drivers/clk/sunxi/Makefile +@@ -12,6 +12,7 @@ obj-$(CONFIG_CLK_SUNIV_F1C100S) += clk_f + obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o + obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o + obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o ++obj-$(CONFIG_CLK_SUN6I_A31_APB0) += clk_a31_apb0.o + obj-$(CONFIG_CLK_SUN6I_A31_R) += clk_a31_r.o + obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o + obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o +--- /dev/null ++++ b/drivers/clk/sunxi/clk_a31_apb0.c +@@ -0,0 +1,97 @@ ++// SPDX-License-Identifier: (GPL-2.0+ OR MIT) ++/* ++ * Copyright (C) Samuel Holland ++ */ ++ ++#include ++#include ++#include ++#include ++ ++static struct ccu_clk_gate sun6i_apb0_gates[] = { ++ [0] = GATE(0x028, BIT(0)), ++ [1] = GATE(0x028, BIT(1)), ++ [2] = GATE(0x028, BIT(2)), ++ [3] = GATE(0x028, BIT(3)), ++ [4] = GATE(0x028, BIT(4)), ++ [5] = GATE(0x028, BIT(5)), ++ [6] = GATE(0x028, BIT(6)), ++ [7] = GATE(0x028, BIT(7)), ++}; ++ ++static struct ccu_reset sun6i_apb0_resets[] = { ++ [0] = RESET(0x0b0, BIT(0)), ++ [1] = RESET(0x0b0, BIT(1)), ++ [2] = RESET(0x0b0, BIT(2)), ++ [3] = RESET(0x0b0, BIT(3)), ++ [4] = RESET(0x0b0, BIT(4)), ++ [5] = RESET(0x0b0, BIT(5)), ++ [6] = RESET(0x0b0, BIT(6)), ++ [7] = RESET(0x0b0, BIT(7)), ++}; ++ ++const struct ccu_desc sun6i_apb0_clk_desc = { ++ .gates = sun6i_apb0_gates, ++ .resets = sun6i_apb0_resets, ++ .num_gates = ARRAY_SIZE(sun6i_apb0_gates), ++ .num_resets = ARRAY_SIZE(sun6i_apb0_resets), ++}; ++ ++static int sun6i_apb0_of_to_plat(struct udevice *dev) ++{ ++ struct ccu_plat *plat = dev_get_plat(dev); ++ ++ plat->base = dev_read_addr_ptr(dev->parent); ++ if (!plat->base) ++ return -ENOMEM; ++ ++ plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); ++ if (!plat->desc) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static const struct udevice_id sun6i_apb0_clk_ids[] = { ++ { .compatible = "allwinner,sun6i-a31-apb0-gates-clk", ++ .data = (ulong)&sun6i_apb0_clk_desc }, ++ { .compatible = "allwinner,sun8i-a23-apb0-gates-clk", ++ .data = (ulong)&sun6i_apb0_clk_desc }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sun6i_apb0_clk) = { ++ .name = "sun6i_apb0_clk", ++ .id = UCLASS_CLK, ++ .of_match = sun6i_apb0_clk_ids, ++ .of_to_plat = sun6i_apb0_of_to_plat, ++ .plat_auto = sizeof(struct ccu_plat), ++ .ops = &sunxi_clk_ops, ++}; ++ ++static const struct udevice_id sun6i_apb0_reset_ids[] = { ++ { .compatible = "allwinner,sun6i-a31-clock-reset", ++ .data = (ulong)&sun6i_apb0_clk_desc }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sun6i_apb0_reset) = { ++ .name = "sun6i_apb0_reset", ++ .id = UCLASS_RESET, ++ .of_match = sun6i_apb0_reset_ids, ++ .of_to_plat = sun6i_apb0_of_to_plat, ++ .plat_auto = sizeof(struct ccu_plat), ++ .ops = &sunxi_reset_ops, ++}; ++ ++static const struct udevice_id sun6i_prcm_mfd_ids[] = { ++ { .compatible = "allwinner,sun6i-a31-prcm" }, ++ { .compatible = "allwinner,sun8i-a23-prcm" }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sun6i_prcm_mfd) = { ++ .name = "sun6i_prcm_mfd", ++ .id = UCLASS_SIMPLE_BUS, ++ .of_match = sun6i_prcm_mfd_ids, ++}; +--- a/include/clk/sunxi.h ++++ b/include/clk/sunxi.h +@@ -86,5 +86,6 @@ struct ccu_plat { + }; + + extern struct clk_ops sunxi_clk_ops; ++extern struct reset_ops sunxi_reset_ops; + + #endif /* _CLK_SUNXI_H */ diff --git a/package/boot/uboot-d1/patches/0014-clk-sunxi-Use-the-right-symbol-in-the-Makefile.patch b/package/boot/uboot-d1/patches/0014-clk-sunxi-Use-the-right-symbol-in-the-Makefile.patch new file mode 100644 index 00000000000000..858af896aa5ff0 --- /dev/null +++ b/package/boot/uboot-d1/patches/0014-clk-sunxi-Use-the-right-symbol-in-the-Makefile.patch @@ -0,0 +1,21 @@ +From 3d97f99cb173422ee8a15b7ec1df83ff61e68204 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 30 Oct 2022 14:28:23 -0500 +Subject: [PATCH 14/90] clk: sunxi: Use the right symbol in the Makefile + +Signed-off-by: Samuel Holland +--- + drivers/clk/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/clk/Makefile ++++ b/drivers/clk/Makefile +@@ -25,7 +25,7 @@ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ + obj-$(CONFIG_ARCH_SOCFPGA) += altera/ + obj-$(CONFIG_ARCH_STM32) += stm32/ + obj-$(CONFIG_ARCH_STM32MP) += stm32/ +-obj-$(CONFIG_ARCH_SUNXI) += sunxi/ ++obj-$(CONFIG_CLK_SUNXI) += sunxi/ + obj-$(CONFIG_CLK_AT91) += at91/ + obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o + obj-$(CONFIG_CLK_BOSTON) += clk_boston.o diff --git a/package/boot/uboot-d1/patches/0015-net-sun8i-emac-Use-common-syscon-setup-for-R40.patch b/package/boot/uboot-d1/patches/0015-net-sun8i-emac-Use-common-syscon-setup-for-R40.patch new file mode 100644 index 00000000000000..41e72bdd2f1193 --- /dev/null +++ b/package/boot/uboot-d1/patches/0015-net-sun8i-emac-Use-common-syscon-setup-for-R40.patch @@ -0,0 +1,100 @@ +From 9766169812418aee10dbc8d40aca27c1c576f521 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 14 Jul 2022 23:39:46 -0500 +Subject: [PATCH 15/90] net: sun8i-emac: Use common syscon setup for R40 + +While R40 puts the EMAC syscon register at a different address from +other variants, the relevant portion of the register's layout is the +same. Factor out the register offset so the same code can be shared +by all variants. This matches what the Linux driver does. + +This change provides two benefits beyond the simplification: + - R40 boards now respect the RX delays from the devicetree + - This resolves a warning on architectures where readl/writel + expect the address to have a pointer type, not phys_addr_t. + +Series-to: sunxi + +Cover-letter: +net: sun8i-emac: Allwinner D1 Support +D1 is a RISC-V SoC containing an EMAC compatible with the A64 EMAC. +However, there are a couple of issues with the driver preventing it +being built for RISC-V. These are resolved by patches 2-3. Patch 1 is +a general cleanup. +END + +Signed-off-by: Samuel Holland +--- + drivers/net/sun8i_emac.c | 29 ++++++++++++----------------- + 1 file changed, 12 insertions(+), 17 deletions(-) + +--- a/drivers/net/sun8i_emac.c ++++ b/drivers/net/sun8i_emac.c +@@ -162,7 +162,7 @@ struct emac_eth_dev { + + enum emac_variant variant; + void *mac_reg; +- phys_addr_t sysctl_reg; ++ void *sysctl_reg; + struct phy_device *phydev; + struct mii_dev *bus; + struct clk tx_clk; +@@ -317,18 +317,7 @@ static int sun8i_emac_set_syscon(struct + { + u32 reg; + +- if (priv->variant == R40_GMAC) { +- /* Select RGMII for R40 */ +- reg = readl(priv->sysctl_reg + 0x164); +- reg |= SC_ETCS_INT_GMII | +- SC_EPIT | +- (CONFIG_GMAC_TX_DELAY << SC_ETXDC_OFFSET); +- +- writel(reg, priv->sysctl_reg + 0x164); +- return 0; +- } +- +- reg = readl(priv->sysctl_reg + 0x30); ++ reg = readl(priv->sysctl_reg); + + reg = sun8i_emac_set_syscon_ephy(priv, reg); + +@@ -369,7 +358,7 @@ static int sun8i_emac_set_syscon(struct + reg |= ((pdata->rx_delay_ps / 100) << SC_ERXDC_OFFSET) + & SC_ERXDC_MASK; + +- writel(reg, priv->sysctl_reg + 0x30); ++ writel(reg, priv->sysctl_reg); + + return 0; + } +@@ -792,6 +781,7 @@ static int sun8i_emac_eth_of_to_plat(str + struct sun8i_eth_pdata *sun8i_pdata = dev_get_plat(dev); + struct eth_pdata *pdata = &sun8i_pdata->eth_pdata; + struct emac_eth_dev *priv = dev_get_priv(dev); ++ phys_addr_t syscon_base; + const fdt32_t *reg; + int node = dev_of_offset(dev); + int offset = 0; +@@ -837,13 +827,18 @@ static int sun8i_emac_eth_of_to_plat(str + __func__); + return -EINVAL; + } +- priv->sysctl_reg = fdt_translate_address((void *)gd->fdt_blob, +- offset, reg); +- if (priv->sysctl_reg == FDT_ADDR_T_NONE) { ++ ++ syscon_base = fdt_translate_address((void *)gd->fdt_blob, offset, reg); ++ if (syscon_base == FDT_ADDR_T_NONE) { + debug("%s: Cannot find syscon base address\n", __func__); + return -EINVAL; + } + ++ if (priv->variant == R40_GMAC) ++ priv->sysctl_reg = (void *)syscon_base + 0x164; ++ else ++ priv->sysctl_reg = (void *)syscon_base + 0x30; ++ + pdata->phy_interface = -1; + priv->phyaddr = -1; + priv->use_internal_phy = false; diff --git a/package/boot/uboot-d1/patches/0016-sunxi-mmc-ignore-card-detect-in-SPL.patch b/package/boot/uboot-d1/patches/0016-sunxi-mmc-ignore-card-detect-in-SPL.patch new file mode 100644 index 00000000000000..a8fe0cb8302dc1 --- /dev/null +++ b/package/boot/uboot-d1/patches/0016-sunxi-mmc-ignore-card-detect-in-SPL.patch @@ -0,0 +1,92 @@ +From 2cde6c8a7c41c13137298c19b4e104e4f5d6851c Mon Sep 17 00:00:00 2001 +From: Andre Przywara +Date: Wed, 13 Jul 2022 17:21:43 +0100 +Subject: [PATCH 16/90] sunxi: mmc: ignore card detect in SPL + +The sunxi MMC code does not use the DM in the SPL, as we don't have a +device tree available that early, also no space for it. +This also means we cannot access the card-detect GPIO information from +there, so we have Kconfig symbols called CONFIG_MMCx_CD_PIN, which each +board has to define. This is a burden, also requires extra GPIO code in +the SPL. +As the SPL is the natural successor of the BootROM (from which we are +loaded), we can actually ignore the CD pin completely, as this is what +the BootROM does as well: CD GPIOs are board specific, but the BootROM +is not, so accesses the MMC devices anyway. + +Remove the card detect code from the non-DM implementation of the sunxi +MMC driver, to get rid of this unneeded code. + +Signed-off-by: Andre Przywara +--- + drivers/mmc/sunxi_mmc.c | 37 ++----------------------------------- + 1 file changed, 2 insertions(+), 35 deletions(-) + +--- a/drivers/mmc/sunxi_mmc.c ++++ b/drivers/mmc/sunxi_mmc.c +@@ -44,22 +44,10 @@ struct sunxi_mmc_priv { + /* support 4 mmc hosts */ + struct sunxi_mmc_priv mmc_host[4]; + +-static int sunxi_mmc_getcd_gpio(int sdc_no) +-{ +- switch (sdc_no) { +- case 0: return sunxi_name_to_gpio(CONFIG_MMC0_CD_PIN); +- case 1: return sunxi_name_to_gpio(CONFIG_MMC1_CD_PIN); +- case 2: return sunxi_name_to_gpio(CONFIG_MMC2_CD_PIN); +- case 3: return sunxi_name_to_gpio(CONFIG_MMC3_CD_PIN); +- } +- return -EINVAL; +-} +- + static int mmc_resource_init(int sdc_no) + { + struct sunxi_mmc_priv *priv = &mmc_host[sdc_no]; + struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; +- int cd_pin, ret = 0; + + debug("init mmc %d resource\n", sdc_no); + +@@ -90,16 +78,7 @@ static int mmc_resource_init(int sdc_no) + } + priv->mmc_no = sdc_no; + +- cd_pin = sunxi_mmc_getcd_gpio(sdc_no); +- if (cd_pin >= 0) { +- ret = gpio_request(cd_pin, "mmc_cd"); +- if (!ret) { +- sunxi_gpio_set_pull(cd_pin, SUNXI_GPIO_PULL_UP); +- ret = gpio_direction_input(cd_pin); +- } +- } +- +- return ret; ++ return 0; + } + #endif + +@@ -523,23 +502,11 @@ static int sunxi_mmc_send_cmd_legacy(str + return sunxi_mmc_send_cmd_common(priv, mmc, cmd, data); + } + +-static int sunxi_mmc_getcd_legacy(struct mmc *mmc) +-{ +- struct sunxi_mmc_priv *priv = mmc->priv; +- int cd_pin; +- +- cd_pin = sunxi_mmc_getcd_gpio(priv->mmc_no); +- if (cd_pin < 0) +- return 1; +- +- return !gpio_get_value(cd_pin); +-} +- ++/* .get_cd is not needed by the SPL */ + static const struct mmc_ops sunxi_mmc_ops = { + .send_cmd = sunxi_mmc_send_cmd_legacy, + .set_ios = sunxi_mmc_set_ios_legacy, + .init = sunxi_mmc_core_init, +- .getcd = sunxi_mmc_getcd_legacy, + }; + + struct mmc *sunxi_mmc_init(int sdc_no) diff --git a/package/boot/uboot-d1/patches/0017-sunxi-mmc-group-non-DM-specific-functions.patch b/package/boot/uboot-d1/patches/0017-sunxi-mmc-group-non-DM-specific-functions.patch new file mode 100644 index 00000000000000..6161c33187a45c --- /dev/null +++ b/package/boot/uboot-d1/patches/0017-sunxi-mmc-group-non-DM-specific-functions.patch @@ -0,0 +1,177 @@ +From 74afc3a4e0ff780eddd859a25de7142e4baeeed5 Mon Sep 17 00:00:00 2001 +From: Andre Przywara +Date: Wed, 13 Jul 2022 17:21:44 +0100 +Subject: [PATCH 17/90] sunxi: mmc: group non-DM specific functions + +As the SPL code for sunxi boards does not use the driver model, we have +two mmc_ops structures, one for DM, one for non-DM. The actual hardware +access code is shared, with the respective callback functions using that +common code. + +To make this more obvious and easier to read, reorder the functions to +group them: we first have the common code, then the non-DM bits, and +the proper DM implementation at the end. +Also document this structure in the comment at the beginning of the file. + +No functional change intended. + +Signed-off-by: Andre Przywara +--- + drivers/mmc/sunxi_mmc.c | 117 +++++++++++++++++++++------------------- + 1 file changed, 61 insertions(+), 56 deletions(-) + +--- a/drivers/mmc/sunxi_mmc.c ++++ b/drivers/mmc/sunxi_mmc.c +@@ -5,6 +5,12 @@ + * Aaron + * + * MMC driver for allwinner sunxi platform. ++ * ++ * This driver is used by the (ARM) SPL with the legacy MMC interface, and ++ * by U-Boot proper using the full DM interface. The actual hardware access ++ * code is common, and comes first in this file. ++ * The legacy MMC interface implementation comes next, followed by the ++ * proper DM_MMC implementation at the end. + */ + + #include +@@ -40,48 +46,6 @@ struct sunxi_mmc_priv { + struct mmc_config cfg; + }; + +-#if !CONFIG_IS_ENABLED(DM_MMC) +-/* support 4 mmc hosts */ +-struct sunxi_mmc_priv mmc_host[4]; +- +-static int mmc_resource_init(int sdc_no) +-{ +- struct sunxi_mmc_priv *priv = &mmc_host[sdc_no]; +- struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; +- +- debug("init mmc %d resource\n", sdc_no); +- +- switch (sdc_no) { +- case 0: +- priv->reg = (struct sunxi_mmc *)SUNXI_MMC0_BASE; +- priv->mclkreg = &ccm->sd0_clk_cfg; +- break; +- case 1: +- priv->reg = (struct sunxi_mmc *)SUNXI_MMC1_BASE; +- priv->mclkreg = &ccm->sd1_clk_cfg; +- break; +-#ifdef SUNXI_MMC2_BASE +- case 2: +- priv->reg = (struct sunxi_mmc *)SUNXI_MMC2_BASE; +- priv->mclkreg = &ccm->sd2_clk_cfg; +- break; +-#endif +-#ifdef SUNXI_MMC3_BASE +- case 3: +- priv->reg = (struct sunxi_mmc *)SUNXI_MMC3_BASE; +- priv->mclkreg = &ccm->sd3_clk_cfg; +- break; +-#endif +- default: +- printf("Wrong mmc number %d\n", sdc_no); +- return -1; +- } +- priv->mmc_no = sdc_no; +- +- return 0; +-} +-#endif +- + /* + * All A64 and later MMC controllers feature auto-calibration. This would + * normally be detected via the compatible string, but we need something +@@ -269,19 +233,6 @@ static int sunxi_mmc_set_ios_common(stru + return 0; + } + +-#if !CONFIG_IS_ENABLED(DM_MMC) +-static int sunxi_mmc_core_init(struct mmc *mmc) +-{ +- struct sunxi_mmc_priv *priv = mmc->priv; +- +- /* Reset controller */ +- writel(SUNXI_MMC_GCTRL_RESET, &priv->reg->gctrl); +- udelay(1000); +- +- return 0; +-} +-#endif +- + static int mmc_trans_data_by_cpu(struct sunxi_mmc_priv *priv, struct mmc *mmc, + struct mmc_data *data) + { +@@ -486,7 +437,60 @@ out: + return error; + } + ++/* non-DM code here is used by the (ARM) SPL only */ ++ + #if !CONFIG_IS_ENABLED(DM_MMC) ++/* support 4 mmc hosts */ ++struct sunxi_mmc_priv mmc_host[4]; ++ ++static int mmc_resource_init(int sdc_no) ++{ ++ struct sunxi_mmc_priv *priv = &mmc_host[sdc_no]; ++ struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; ++ ++ debug("init mmc %d resource\n", sdc_no); ++ ++ switch (sdc_no) { ++ case 0: ++ priv->reg = (struct sunxi_mmc *)SUNXI_MMC0_BASE; ++ priv->mclkreg = &ccm->sd0_clk_cfg; ++ break; ++ case 1: ++ priv->reg = (struct sunxi_mmc *)SUNXI_MMC1_BASE; ++ priv->mclkreg = &ccm->sd1_clk_cfg; ++ break; ++#ifdef SUNXI_MMC2_BASE ++ case 2: ++ priv->reg = (struct sunxi_mmc *)SUNXI_MMC2_BASE; ++ priv->mclkreg = &ccm->sd2_clk_cfg; ++ break; ++#endif ++#ifdef SUNXI_MMC3_BASE ++ case 3: ++ priv->reg = (struct sunxi_mmc *)SUNXI_MMC3_BASE; ++ priv->mclkreg = &ccm->sd3_clk_cfg; ++ break; ++#endif ++ default: ++ printf("Wrong mmc number %d\n", sdc_no); ++ return -1; ++ } ++ priv->mmc_no = sdc_no; ++ ++ return 0; ++} ++ ++static int sunxi_mmc_core_init(struct mmc *mmc) ++{ ++ struct sunxi_mmc_priv *priv = mmc->priv; ++ ++ /* Reset controller */ ++ writel(SUNXI_MMC_GCTRL_RESET, &priv->reg->gctrl); ++ udelay(1000); ++ ++ return 0; ++} ++ + static int sunxi_mmc_set_ios_legacy(struct mmc *mmc) + { + struct sunxi_mmc_priv *priv = mmc->priv; +@@ -562,7 +566,8 @@ struct mmc *sunxi_mmc_init(int sdc_no) + + return mmc_create(cfg, priv); + } +-#else ++ ++#else /* CONFIG_DM_MMC code below, as used by U-Boot proper */ + + static int sunxi_mmc_set_ios(struct udevice *dev) + { diff --git a/package/boot/uboot-d1/patches/0018-sunxi-remove-CONFIG_MMC-_CD_PIN.patch b/package/boot/uboot-d1/patches/0018-sunxi-remove-CONFIG_MMC-_CD_PIN.patch new file mode 100644 index 00000000000000..a87b6e26ce3bc1 --- /dev/null +++ b/package/boot/uboot-d1/patches/0018-sunxi-remove-CONFIG_MMC-_CD_PIN.patch @@ -0,0 +1,509 @@ +From bcc2e01668041c146d964ed5f77b819dcc35b3e2 Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 15:07:47 +0000 +Subject: [PATCH 18/90] sunxi: remove CONFIG_MMC?_CD_PIN + +For legacy reasons we were defining the card detect GPIO for all sunxi +boards in each board's defconfig. +There is actually no need for a card-detect check in the SPL code (which +consequently has been removed already), and also in U-Boot proper we +have DM code to query the CD GPIO name from the device tree. + +That means we don't have any user of that information left, so can +remove the definitions from the defconfigs. + +Signed-off-by: Andre Przywara +Signed-off-by: Zoltan HERPAI +--- + arch/arm/mach-sunxi/Kconfig | 27 -------------------- + configs/A10-OLinuXino-Lime_defconfig | 1 - + configs/A10s-OLinuXino-M_defconfig | 2 -- + configs/A13-OLinuXino_defconfig | 1 - + configs/A20-OLinuXino-Lime2-eMMC_defconfig | 1 - + configs/A20-OLinuXino-Lime_defconfig | 1 - + configs/A20-OLinuXino_MICRO-eMMC_defconfig | 1 - + configs/A20-OLinuXino_MICRO_defconfig | 2 -- + configs/A20-Olimex-SOM-EVB_defconfig | 2 -- + configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 1 - + configs/Bananapi_M2_Ultra_defconfig | 1 - + configs/Bananapi_m2m_defconfig | 1 - + configs/Cubieboard2_defconfig | 1 - + configs/Cubieboard4_defconfig | 1 - + configs/Cubieboard_defconfig | 1 - + configs/Itead_Ibox_A20_defconfig | 1 - + configs/Lamobo_R1_defconfig | 1 - + configs/Mele_M3_defconfig | 1 - + configs/Mele_M5_defconfig | 1 - + configs/Merrii_A80_Optimus_defconfig | 1 - + configs/Orangepi_mini_defconfig | 2 -- + configs/Sinlinx_SinA31s_defconfig | 1 - + configs/Sinlinx_SinA33_defconfig | 1 - + configs/Sunchip_CX-A99_defconfig | 1 - + configs/UTOO_P66_defconfig | 1 - + configs/Yones_Toptech_BD1078_defconfig | 2 -- + configs/bananapi_m2_zero_defconfig | 1 - + configs/bananapi_m64_defconfig | 1 - + configs/beelink_gs1_defconfig | 1 - + configs/nanopi_m1_plus_defconfig | 1 - + configs/oceanic_5205_5inmfd_defconfig | 1 - + configs/orangepi_3_defconfig | 1 - + configs/orangepi_lite2_defconfig | 1 - + configs/orangepi_one_plus_defconfig | 1 - + configs/orangepi_zero2_defconfig | 1 - + configs/orangepi_zero_plus2_defconfig | 1 - + configs/orangepi_zero_plus2_h3_defconfig | 1 - + configs/parrot_r16_defconfig | 1 - + configs/pine64-lts_defconfig | 1 - + configs/pine_h64_defconfig | 1 - + configs/sopine_baseboard_defconfig | 1 - + configs/tanix_tx6_defconfig | 1 - + 42 files changed, 73 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -652,33 +652,6 @@ config MACPWR + Set the pin used to power the MAC. This takes a string in the format + understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + +-config MMC0_CD_PIN +- string "Card detect pin for mmc0" +- default "PF6" if MACH_SUN8I_A83T || MACH_SUNXI_H3_H5 || MACH_SUN50I +- 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 MMC1_PINS_PH + bool "Pins for mmc1 are on Port H" + depends on MACH_SUN4I || MACH_SUN7I || MACH_SUN8I_R40 +--- a/configs/A10-OLinuXino-Lime_defconfig ++++ b/configs/A10-OLinuXino-Lime_defconfig +@@ -6,7 +6,6 @@ CONFIG_MACH_SUN4I=y + CONFIG_DRAM_CLK=480 + CONFIG_DRAM_EMR1=4 + CONFIG_SYS_CLK_FREQ=912000000 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_I2C1_ENABLE=y + CONFIG_SATAPWR="PC3" + CONFIG_AHCI=y +--- a/configs/A10s-OLinuXino-M_defconfig ++++ b/configs/A10s-OLinuXino-M_defconfig +@@ -4,8 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun5i-a10s-o + CONFIG_SPL=y + CONFIG_MACH_SUN5I=y + CONFIG_DRAM_CLK=432 +-CONFIG_MMC0_CD_PIN="PG1" +-CONFIG_MMC1_CD_PIN="PG13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=1 + CONFIG_USB1_VBUS_PIN="PB10" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/A13-OLinuXino_defconfig ++++ b/configs/A13-OLinuXino_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN5I=y + CONFIG_DRAM_CLK=408 + CONFIG_DRAM_EMR1=0 +-CONFIG_MMC0_CD_PIN="PG0" + CONFIG_USB0_VBUS_DET="PG1" + CONFIG_USB1_VBUS_PIN="PG11" + CONFIG_AXP_GPIO=y +--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig ++++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="PC17" + CONFIG_USB0_VBUS_DET="PH5" +--- a/configs/A20-OLinuXino-Lime_defconfig ++++ b/configs/A20-OLinuXino-Lime_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_I2C1_ENABLE=y + CONFIG_SATAPWR="PC3" + CONFIG_AHCI=y +--- a/configs/A20-OLinuXino_MICRO-eMMC_defconfig ++++ b/configs/A20-OLinuXino_MICRO-eMMC_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_I2C1_ENABLE=y + CONFIG_VIDEO_VGA=y +--- a/configs/A20-OLinuXino_MICRO_defconfig ++++ b/configs/A20-OLinuXino_MICRO_defconfig +@@ -4,8 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" +-CONFIG_MMC3_CD_PIN="PH11" + CONFIG_MMC_SUNXI_SLOT_EXTRA=3 + CONFIG_I2C1_ENABLE=y + CONFIG_VIDEO_VGA=y +--- a/configs/A20-Olimex-SOM-EVB_defconfig ++++ b/configs/A20-Olimex-SOM-EVB_defconfig +@@ -4,8 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" +-CONFIG_MMC3_CD_PIN="PH0" + CONFIG_MMC_SUNXI_SLOT_EXTRA=3 + CONFIG_USB0_VBUS_PIN="PB9" + CONFIG_USB0_VBUS_DET="PH5" +--- a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig ++++ b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-ol + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="PC17" + CONFIG_USB0_VBUS_DET="PH5" +--- a/configs/Bananapi_M2_Ultra_defconfig ++++ b/configs/Bananapi_M2_Ultra_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN8I_R40=y + CONFIG_DRAM_CLK=576 + CONFIG_MACPWR="PA17" +-CONFIG_MMC0_CD_PIN="PH13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB1_VBUS_PIN="PH23" + CONFIG_USB2_VBUS_PIN="PH23" +--- a/configs/Bananapi_m2m_defconfig ++++ b/configs/Bananapi_m2m_defconfig +@@ -6,7 +6,6 @@ CONFIG_MACH_SUN8I_A33=y + CONFIG_DRAM_CLK=600 + CONFIG_DRAM_ZQ=15291 + CONFIG_DRAM_ODT_EN=y +-CONFIG_MMC0_CD_PIN="PB4" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_ID_DET="PH8" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/Cubieboard2_defconfig ++++ b/configs/Cubieboard2_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cu + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=480 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_SATAPWR="PB8" + CONFIG_AHCI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/Cubieboard4_defconfig ++++ b/configs/Cubieboard4_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun9i-a80-cu + CONFIG_SPL=y + CONFIG_MACH_SUN9I=y + CONFIG_DRAM_CLK=672 +-CONFIG_MMC0_CD_PIN="PH18" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="AXP0-VBUS-ENABLE" + CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT" +--- a/configs/Cubieboard_defconfig ++++ b/configs/Cubieboard_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-cu + CONFIG_SPL=y + CONFIG_MACH_SUN4I=y + CONFIG_DRAM_CLK=480 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_SATAPWR="PB8" + CONFIG_AHCI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/Itead_Ibox_A20_defconfig ++++ b/configs/Itead_Ibox_A20_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-it + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=480 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_SATAPWR="PB8" + CONFIG_AHCI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/Lamobo_R1_defconfig ++++ b/configs/Lamobo_R1_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=432 + CONFIG_MACPWR="PH23" +-CONFIG_MMC0_CD_PIN="PH10" + CONFIG_SATAPWR="PB3" + CONFIG_GMAC_TX_DELAY=4 + CONFIG_AHCI=y +--- a/configs/Mele_M3_defconfig ++++ b/configs/Mele_M3_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-m3 + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=384 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_VIDEO_VGA=y + CONFIG_VIDEO_COMPOSITE=y +--- a/configs/Mele_M5_defconfig ++++ b/configs/Mele_M5_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=432 + CONFIG_DRAM_ZQ=122 +-CONFIG_MMC0_CD_PIN="PH1" + CONFIG_VIDEO_COMPOSITE=y + CONFIG_AHCI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/Merrii_A80_Optimus_defconfig ++++ b/configs/Merrii_A80_Optimus_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun9i-a80-op + CONFIG_SPL=y + CONFIG_MACH_SUN9I=y + CONFIG_DRAM_CLK=672 +-CONFIG_MMC0_CD_PIN="PH18" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="AXP0-VBUS-ENABLE" + CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT" +--- a/configs/Orangepi_mini_defconfig ++++ b/configs/Orangepi_mini_defconfig +@@ -5,8 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=432 + CONFIG_MACPWR="PH23" +-CONFIG_MMC0_CD_PIN="PH10" +-CONFIG_MMC3_CD_PIN="PH11" + CONFIG_MMC_SUNXI_SLOT_EXTRA=3 + CONFIG_USB1_VBUS_PIN="PH26" + CONFIG_USB2_VBUS_PIN="PH22" +--- a/configs/Sinlinx_SinA31s_defconfig ++++ b/configs/Sinlinx_SinA31s_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN6I=y + CONFIG_DRAM_CLK=432 + CONFIG_DRAM_ZQ=251 +-CONFIG_MMC0_CD_PIN="PA4" + CONFIG_MMC_SUNXI_SLOT_EXTRA=3 + CONFIG_USB1_VBUS_PIN="" + CONFIG_USB2_VBUS_PIN="" +--- a/configs/Sinlinx_SinA33_defconfig ++++ b/configs/Sinlinx_SinA33_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN8I_A33=y + CONFIG_DRAM_CLK=552 + CONFIG_DRAM_ZQ=15291 +-CONFIG_MMC0_CD_PIN="PB4" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_ID_DET="PH8" + CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:66000,le:90,ri:160,up:3,lo:127,hs:70,vs:20,sync:3,vmode:0" +--- a/configs/Sunchip_CX-A99_defconfig ++++ b/configs/Sunchip_CX-A99_defconfig +@@ -6,7 +6,6 @@ CONFIG_MACH_SUN9I=y + CONFIG_DRAM_CLK=600 + CONFIG_DRAM_ZQ=3881915 + CONFIG_DRAM_ODT_EN=y +-CONFIG_MMC0_CD_PIN="PH17" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="PH15" + CONFIG_USB1_VBUS_PIN="PL7" +--- a/configs/UTOO_P66_defconfig ++++ b/configs/UTOO_P66_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN5I=y + CONFIG_DRAM_CLK=432 + CONFIG_DRAM_EMR1=0 +-CONFIG_MMC0_CD_PIN="PG0" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_VBUS_PIN="PB04" + CONFIG_USB0_VBUS_DET="PG01" +--- a/configs/Yones_Toptech_BD1078_defconfig ++++ b/configs/Yones_Toptech_BD1078_defconfig +@@ -4,8 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-yo + CONFIG_SPL=y + CONFIG_MACH_SUN7I=y + CONFIG_DRAM_CLK=408 +-CONFIG_MMC0_CD_PIN="PH1" +-CONFIG_MMC1_CD_PIN="PH2" + CONFIG_MMC1_PINS_PH=y + CONFIG_MMC_SUNXI_SLOT_EXTRA=1 + CONFIG_USB0_VBUS_PIN="PB9" +--- a/configs/bananapi_m2_zero_defconfig ++++ b/configs/bananapi_m2_zero_defconfig +@@ -4,5 +4,4 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plu + CONFIG_SPL=y + CONFIG_MACH_SUN8I_H3=y + CONFIG_DRAM_CLK=408 +-CONFIG_MMC0_CD_PIN="" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/bananapi_m64_defconfig ++++ b/configs/bananapi_m64_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-b + CONFIG_SPL=y + CONFIG_MACH_SUN50I=y + CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y +-CONFIG_MMC0_CD_PIN="PH13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUPPORT_EMMC_BOOT=y +--- a/configs/beelink_gs1_defconfig ++++ b/configs/beelink_gs1_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-be + CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_LPDDR3=y +-CONFIG_MMC0_CD_PIN="PF6" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_PSCI_RESET is not set + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/nanopi_m1_plus_defconfig ++++ b/configs/nanopi_m1_plus_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN8I_H3=y + CONFIG_DRAM_CLK=408 + CONFIG_MACPWR="PD6" +-CONFIG_MMC0_CD_PIN="PH13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUN8I_EMAC=y +--- a/configs/oceanic_5205_5inmfd_defconfig ++++ b/configs/oceanic_5205_5inmfd_defconfig +@@ -7,7 +7,6 @@ CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y + CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y + CONFIG_DRAM_CLK=552 + CONFIG_DRAM_ZQ=3881949 +-CONFIG_MMC0_CD_PIN="" + CONFIG_SPL_SPI_SUNXI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUN8I_EMAC=y +--- a/configs/orangepi_3_defconfig ++++ b/configs/orangepi_3_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-or + CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_LPDDR3=y +-CONFIG_MMC0_CD_PIN="PF6" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_BLUETOOTH_DT_DEVICE_FIXUP="brcm,bcm4345c5" + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/orangepi_lite2_defconfig ++++ b/configs/orangepi_lite2_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-or + CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_LPDDR3=y +-CONFIG_MMC0_CD_PIN="PF6" + # CONFIG_PSCI_RESET is not set + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_USB_EHCI_HCD=y +--- a/configs/orangepi_one_plus_defconfig ++++ b/configs/orangepi_one_plus_defconfig +@@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-or + CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_LPDDR3=y +-CONFIG_MMC0_CD_PIN="PF6" + # CONFIG_PSCI_RESET is not set + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_USB_EHCI_HCD=y +--- a/configs/orangepi_zero2_defconfig ++++ b/configs/orangepi_zero2_defconfig +@@ -7,7 +7,6 @@ CONFIG_DRAM_SUN50I_H616_READ_CALIBRATION + CONFIG_DRAM_SUN50I_H616_READ_TRAINING=y + CONFIG_DRAM_SUN50I_H616_WRITE_TRAINING=y + CONFIG_MACH_SUN50I_H616=y +-CONFIG_MMC0_CD_PIN="PF6" + CONFIG_R_I2C_ENABLE=y + CONFIG_SPL_SPI_SUNXI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/orangepi_zero_plus2_defconfig ++++ b/configs/orangepi_zero_plus2_defconfig +@@ -6,7 +6,6 @@ CONFIG_MACH_SUN50I_H5=y + CONFIG_DRAM_CLK=672 + CONFIG_DRAM_ZQ=3881977 + # CONFIG_DRAM_ODT_EN is not set +-CONFIG_MMC0_CD_PIN="PH13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUN8I_EMAC=y +--- a/configs/orangepi_zero_plus2_h3_defconfig ++++ b/configs/orangepi_zero_plus2_h3_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN8I_H3=y + CONFIG_DRAM_CLK=672 + # CONFIG_DRAM_ODT_EN is not set +-CONFIG_MMC0_CD_PIN="PH13" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUN8I_EMAC=y +--- a/configs/parrot_r16_defconfig ++++ b/configs/parrot_r16_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN8I_A33=y + CONFIG_DRAM_CLK=600 + CONFIG_DRAM_ZQ=15291 +-CONFIG_MMC0_CD_PIN="PD14" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB0_ID_DET="PD10" + CONFIG_USB1_VBUS_PIN="PD12" +--- a/configs/pine64-lts_defconfig ++++ b/configs/pine64-lts_defconfig +@@ -6,7 +6,6 @@ CONFIG_MACH_SUN50I=y + CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y + CONFIG_DRAM_CLK=552 + CONFIG_DRAM_ZQ=3881949 +-CONFIG_MMC0_CD_PIN="" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_SPL_SPI_SUNXI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/pine_h64_defconfig ++++ b/configs/pine_h64_defconfig +@@ -5,7 +5,6 @@ CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_LPDDR3=y + CONFIG_MACPWR="PC16" +-CONFIG_MMC0_CD_PIN="PF6" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_USB3_VBUS_PIN="PL5" + CONFIG_SPL_SPI_SUNXI=y +--- a/configs/sopine_baseboard_defconfig ++++ b/configs/sopine_baseboard_defconfig +@@ -7,7 +7,6 @@ CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y + CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y + CONFIG_DRAM_CLK=552 + CONFIG_DRAM_ZQ=3881949 +-CONFIG_MMC0_CD_PIN="" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + CONFIG_SPL_SPI_SUNXI=y + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +--- a/configs/tanix_tx6_defconfig ++++ b/configs/tanix_tx6_defconfig +@@ -5,6 +5,5 @@ CONFIG_SPL=y + CONFIG_MACH_SUN50I_H6=y + CONFIG_SUNXI_DRAM_H6_DDR3_1333=y + CONFIG_DRAM_CLK=648 +-CONFIG_MMC0_CD_PIN="PF6" + CONFIG_MMC_SUNXI_SLOT_EXTRA=2 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set diff --git a/package/boot/uboot-d1/patches/0019-sunxi-mmc-Move-header-to-the-driver-directory.patch b/package/boot/uboot-d1/patches/0019-sunxi-mmc-Move-header-to-the-driver-directory.patch new file mode 100644 index 00000000000000..3299ad49dea0a0 --- /dev/null +++ b/package/boot/uboot-d1/patches/0019-sunxi-mmc-Move-header-to-the-driver-directory.patch @@ -0,0 +1,323 @@ +From 4c0c00e7131baf410702555342337c178dd0de98 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 30 Oct 2022 16:04:47 -0500 +Subject: [PATCH 19/90] sunxi: mmc: Move header to the driver directory + +The MMC controller driver is (and ought to be) the only user of these +register definitions. Put them in a header next to the driver to remove +the dependency on a specific ARM platform's headers. + +Due to the sunxi_mmc_init() prototype, the file was not renamed. None of +the register definitions were changed. + +Signed-off-by: Samuel Holland +--- + arch/arm/include/asm/arch-sunxi/mmc.h | 139 +------------------------- + drivers/mmc/sunxi_mmc.c | 4 + + drivers/mmc/sunxi_mmc.h | 138 +++++++++++++++++++++++++ + 3 files changed, 146 insertions(+), 135 deletions(-) + create mode 100644 drivers/mmc/sunxi_mmc.h + +--- a/arch/arm/include/asm/arch-sunxi/mmc.h ++++ b/arch/arm/include/asm/arch-sunxi/mmc.h +@@ -1,139 +1,8 @@ + /* SPDX-License-Identifier: GPL-2.0+ */ +-/* +- * (C) Copyright 2007-2011 +- * Allwinner Technology Co., Ltd. +- * Aaron +- * +- * MMC register definition for allwinner sunxi platform. +- */ + +-#ifndef _SUNXI_MMC_H +-#define _SUNXI_MMC_H +- +-#include +- +-struct sunxi_mmc { +- u32 gctrl; /* 0x00 global control */ +- u32 clkcr; /* 0x04 clock control */ +- u32 timeout; /* 0x08 time out */ +- u32 width; /* 0x0c bus width */ +- u32 blksz; /* 0x10 block size */ +- u32 bytecnt; /* 0x14 byte count */ +- u32 cmd; /* 0x18 command */ +- u32 arg; /* 0x1c argument */ +- u32 resp0; /* 0x20 response 0 */ +- u32 resp1; /* 0x24 response 1 */ +- u32 resp2; /* 0x28 response 2 */ +- u32 resp3; /* 0x2c response 3 */ +- u32 imask; /* 0x30 interrupt mask */ +- u32 mint; /* 0x34 masked interrupt status */ +- u32 rint; /* 0x38 raw interrupt status */ +- u32 status; /* 0x3c status */ +- u32 ftrglevel; /* 0x40 FIFO threshold watermark*/ +- u32 funcsel; /* 0x44 function select */ +- u32 cbcr; /* 0x48 CIU byte count */ +- u32 bbcr; /* 0x4c BIU byte count */ +- u32 dbgc; /* 0x50 debug enable */ +- u32 res0; /* 0x54 reserved */ +- u32 a12a; /* 0x58 Auto command 12 argument */ +- u32 ntsr; /* 0x5c New timing set register */ +- u32 res1[8]; +- u32 dmac; /* 0x80 internal DMA control */ +- u32 dlba; /* 0x84 internal DMA descr list base address */ +- u32 idst; /* 0x88 internal DMA status */ +- u32 idie; /* 0x8c internal DMA interrupt enable */ +- u32 chda; /* 0x90 */ +- u32 cbda; /* 0x94 */ +- u32 res2[26]; +-#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_SUN50I_GEN_H6) +- u32 res3[17]; +- u32 samp_dl; +- u32 res4[46]; +-#endif +- u32 fifo; /* 0x100 / 0x200 FIFO access address */ +-}; +- +-#define SUNXI_MMC_CLK_POWERSAVE (0x1 << 17) +-#define SUNXI_MMC_CLK_ENABLE (0x1 << 16) +-#define SUNXI_MMC_CLK_DIVIDER_MASK (0xff) +- +-#define SUNXI_MMC_GCTRL_SOFT_RESET (0x1 << 0) +-#define SUNXI_MMC_GCTRL_FIFO_RESET (0x1 << 1) +-#define SUNXI_MMC_GCTRL_DMA_RESET (0x1 << 2) +-#define SUNXI_MMC_GCTRL_RESET (SUNXI_MMC_GCTRL_SOFT_RESET|\ +- SUNXI_MMC_GCTRL_FIFO_RESET|\ +- SUNXI_MMC_GCTRL_DMA_RESET) +-#define SUNXI_MMC_GCTRL_DMA_ENABLE (0x1 << 5) +-#define SUNXI_MMC_GCTRL_ACCESS_BY_AHB (0x1 << 31) +- +-#define SUNXI_MMC_CMD_RESP_EXPIRE (0x1 << 6) +-#define SUNXI_MMC_CMD_LONG_RESPONSE (0x1 << 7) +-#define SUNXI_MMC_CMD_CHK_RESPONSE_CRC (0x1 << 8) +-#define SUNXI_MMC_CMD_DATA_EXPIRE (0x1 << 9) +-#define SUNXI_MMC_CMD_WRITE (0x1 << 10) +-#define SUNXI_MMC_CMD_AUTO_STOP (0x1 << 12) +-#define SUNXI_MMC_CMD_WAIT_PRE_OVER (0x1 << 13) +-#define SUNXI_MMC_CMD_SEND_INIT_SEQ (0x1 << 15) +-#define SUNXI_MMC_CMD_UPCLK_ONLY (0x1 << 21) +-#define SUNXI_MMC_CMD_START (0x1 << 31) +- +-#define SUNXI_MMC_RINT_RESP_ERROR (0x1 << 1) +-#define SUNXI_MMC_RINT_COMMAND_DONE (0x1 << 2) +-#define SUNXI_MMC_RINT_DATA_OVER (0x1 << 3) +-#define SUNXI_MMC_RINT_TX_DATA_REQUEST (0x1 << 4) +-#define SUNXI_MMC_RINT_RX_DATA_REQUEST (0x1 << 5) +-#define SUNXI_MMC_RINT_RESP_CRC_ERROR (0x1 << 6) +-#define SUNXI_MMC_RINT_DATA_CRC_ERROR (0x1 << 7) +-#define SUNXI_MMC_RINT_RESP_TIMEOUT (0x1 << 8) +-#define SUNXI_MMC_RINT_DATA_TIMEOUT (0x1 << 9) +-#define SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE (0x1 << 10) +-#define SUNXI_MMC_RINT_FIFO_RUN_ERROR (0x1 << 11) +-#define SUNXI_MMC_RINT_HARD_WARE_LOCKED (0x1 << 12) +-#define SUNXI_MMC_RINT_START_BIT_ERROR (0x1 << 13) +-#define SUNXI_MMC_RINT_AUTO_COMMAND_DONE (0x1 << 14) +-#define SUNXI_MMC_RINT_END_BIT_ERROR (0x1 << 15) +-#define SUNXI_MMC_RINT_SDIO_INTERRUPT (0x1 << 16) +-#define SUNXI_MMC_RINT_CARD_INSERT (0x1 << 30) +-#define SUNXI_MMC_RINT_CARD_REMOVE (0x1 << 31) +-#define SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT \ +- (SUNXI_MMC_RINT_RESP_ERROR | \ +- SUNXI_MMC_RINT_RESP_CRC_ERROR | \ +- SUNXI_MMC_RINT_DATA_CRC_ERROR | \ +- SUNXI_MMC_RINT_RESP_TIMEOUT | \ +- SUNXI_MMC_RINT_DATA_TIMEOUT | \ +- SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE | \ +- SUNXI_MMC_RINT_FIFO_RUN_ERROR | \ +- SUNXI_MMC_RINT_HARD_WARE_LOCKED | \ +- SUNXI_MMC_RINT_START_BIT_ERROR | \ +- SUNXI_MMC_RINT_END_BIT_ERROR) /* 0xbfc2 */ +-#define SUNXI_MMC_RINT_INTERRUPT_DONE_BIT \ +- (SUNXI_MMC_RINT_AUTO_COMMAND_DONE | \ +- SUNXI_MMC_RINT_DATA_OVER | \ +- SUNXI_MMC_RINT_COMMAND_DONE | \ +- SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE) +- +-#define SUNXI_MMC_STATUS_RXWL_FLAG (0x1 << 0) +-#define SUNXI_MMC_STATUS_TXWL_FLAG (0x1 << 1) +-#define SUNXI_MMC_STATUS_FIFO_EMPTY (0x1 << 2) +-#define SUNXI_MMC_STATUS_FIFO_FULL (0x1 << 3) +-#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) +- +-#define SUNXI_MMC_IDMAC_RESET (0x1 << 0) +-#define SUNXI_MMC_IDMAC_FIXBURST (0x1 << 1) +-#define SUNXI_MMC_IDMAC_ENABLE (0x1 << 7) +- +-#define SUNXI_MMC_IDIE_TXIRQ (0x1 << 0) +-#define SUNXI_MMC_IDIE_RXIRQ (0x1 << 1) +- +-#define SUNXI_MMC_COMMON_CLK_GATE (1 << 16) +-#define SUNXI_MMC_COMMON_RESET (1 << 18) +- +-#define SUNXI_MMC_CAL_DL_SW_EN (0x1 << 7) ++#ifndef _ASM_ARCH_MMC_H_ ++#define _ASM_ARCH_MMC_H_ + + struct mmc *sunxi_mmc_init(int sdc_no); +-#endif /* _SUNXI_MMC_H */ ++ ++#endif /* _ASM_ARCH_MMC_H_ */ +--- a/drivers/mmc/sunxi_mmc.c ++++ b/drivers/mmc/sunxi_mmc.c +@@ -25,9 +25,13 @@ + #include + #include + #include ++#if !CONFIG_IS_ENABLED(DM_MMC) + #include ++#endif + #include + ++#include "sunxi_mmc.h" ++ + #ifndef CCM_MMC_CTRL_MODE_SEL_NEW + #define CCM_MMC_CTRL_MODE_SEL_NEW 0 + #endif +--- /dev/null ++++ b/drivers/mmc/sunxi_mmc.h +@@ -0,0 +1,138 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * (C) Copyright 2007-2011 ++ * Allwinner Technology Co., Ltd. ++ * Aaron ++ * ++ * MMC register definition for allwinner sunxi platform. ++ */ ++ ++#ifndef _SUNXI_MMC_H ++#define _SUNXI_MMC_H ++ ++#include ++ ++struct sunxi_mmc { ++ u32 gctrl; /* 0x00 global control */ ++ u32 clkcr; /* 0x04 clock control */ ++ u32 timeout; /* 0x08 time out */ ++ u32 width; /* 0x0c bus width */ ++ u32 blksz; /* 0x10 block size */ ++ u32 bytecnt; /* 0x14 byte count */ ++ u32 cmd; /* 0x18 command */ ++ u32 arg; /* 0x1c argument */ ++ u32 resp0; /* 0x20 response 0 */ ++ u32 resp1; /* 0x24 response 1 */ ++ u32 resp2; /* 0x28 response 2 */ ++ u32 resp3; /* 0x2c response 3 */ ++ u32 imask; /* 0x30 interrupt mask */ ++ u32 mint; /* 0x34 masked interrupt status */ ++ u32 rint; /* 0x38 raw interrupt status */ ++ u32 status; /* 0x3c status */ ++ u32 ftrglevel; /* 0x40 FIFO threshold watermark*/ ++ u32 funcsel; /* 0x44 function select */ ++ u32 cbcr; /* 0x48 CIU byte count */ ++ u32 bbcr; /* 0x4c BIU byte count */ ++ u32 dbgc; /* 0x50 debug enable */ ++ u32 res0; /* 0x54 reserved */ ++ u32 a12a; /* 0x58 Auto command 12 argument */ ++ u32 ntsr; /* 0x5c New timing set register */ ++ u32 res1[8]; ++ u32 dmac; /* 0x80 internal DMA control */ ++ u32 dlba; /* 0x84 internal DMA descr list base address */ ++ u32 idst; /* 0x88 internal DMA status */ ++ u32 idie; /* 0x8c internal DMA interrupt enable */ ++ u32 chda; /* 0x90 */ ++ u32 cbda; /* 0x94 */ ++ u32 res2[26]; ++#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_SUN50I_GEN_H6) ++ u32 res3[17]; ++ u32 samp_dl; ++ u32 res4[46]; ++#endif ++ u32 fifo; /* 0x100 / 0x200 FIFO access address */ ++}; ++ ++#define SUNXI_MMC_CLK_POWERSAVE (0x1 << 17) ++#define SUNXI_MMC_CLK_ENABLE (0x1 << 16) ++#define SUNXI_MMC_CLK_DIVIDER_MASK (0xff) ++ ++#define SUNXI_MMC_GCTRL_SOFT_RESET (0x1 << 0) ++#define SUNXI_MMC_GCTRL_FIFO_RESET (0x1 << 1) ++#define SUNXI_MMC_GCTRL_DMA_RESET (0x1 << 2) ++#define SUNXI_MMC_GCTRL_RESET (SUNXI_MMC_GCTRL_SOFT_RESET|\ ++ SUNXI_MMC_GCTRL_FIFO_RESET|\ ++ SUNXI_MMC_GCTRL_DMA_RESET) ++#define SUNXI_MMC_GCTRL_DMA_ENABLE (0x1 << 5) ++#define SUNXI_MMC_GCTRL_ACCESS_BY_AHB (0x1 << 31) ++ ++#define SUNXI_MMC_CMD_RESP_EXPIRE (0x1 << 6) ++#define SUNXI_MMC_CMD_LONG_RESPONSE (0x1 << 7) ++#define SUNXI_MMC_CMD_CHK_RESPONSE_CRC (0x1 << 8) ++#define SUNXI_MMC_CMD_DATA_EXPIRE (0x1 << 9) ++#define SUNXI_MMC_CMD_WRITE (0x1 << 10) ++#define SUNXI_MMC_CMD_AUTO_STOP (0x1 << 12) ++#define SUNXI_MMC_CMD_WAIT_PRE_OVER (0x1 << 13) ++#define SUNXI_MMC_CMD_SEND_INIT_SEQ (0x1 << 15) ++#define SUNXI_MMC_CMD_UPCLK_ONLY (0x1 << 21) ++#define SUNXI_MMC_CMD_START (0x1 << 31) ++ ++#define SUNXI_MMC_RINT_RESP_ERROR (0x1 << 1) ++#define SUNXI_MMC_RINT_COMMAND_DONE (0x1 << 2) ++#define SUNXI_MMC_RINT_DATA_OVER (0x1 << 3) ++#define SUNXI_MMC_RINT_TX_DATA_REQUEST (0x1 << 4) ++#define SUNXI_MMC_RINT_RX_DATA_REQUEST (0x1 << 5) ++#define SUNXI_MMC_RINT_RESP_CRC_ERROR (0x1 << 6) ++#define SUNXI_MMC_RINT_DATA_CRC_ERROR (0x1 << 7) ++#define SUNXI_MMC_RINT_RESP_TIMEOUT (0x1 << 8) ++#define SUNXI_MMC_RINT_DATA_TIMEOUT (0x1 << 9) ++#define SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE (0x1 << 10) ++#define SUNXI_MMC_RINT_FIFO_RUN_ERROR (0x1 << 11) ++#define SUNXI_MMC_RINT_HARD_WARE_LOCKED (0x1 << 12) ++#define SUNXI_MMC_RINT_START_BIT_ERROR (0x1 << 13) ++#define SUNXI_MMC_RINT_AUTO_COMMAND_DONE (0x1 << 14) ++#define SUNXI_MMC_RINT_END_BIT_ERROR (0x1 << 15) ++#define SUNXI_MMC_RINT_SDIO_INTERRUPT (0x1 << 16) ++#define SUNXI_MMC_RINT_CARD_INSERT (0x1 << 30) ++#define SUNXI_MMC_RINT_CARD_REMOVE (0x1 << 31) ++#define SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT \ ++ (SUNXI_MMC_RINT_RESP_ERROR | \ ++ SUNXI_MMC_RINT_RESP_CRC_ERROR | \ ++ SUNXI_MMC_RINT_DATA_CRC_ERROR | \ ++ SUNXI_MMC_RINT_RESP_TIMEOUT | \ ++ SUNXI_MMC_RINT_DATA_TIMEOUT | \ ++ SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE | \ ++ SUNXI_MMC_RINT_FIFO_RUN_ERROR | \ ++ SUNXI_MMC_RINT_HARD_WARE_LOCKED | \ ++ SUNXI_MMC_RINT_START_BIT_ERROR | \ ++ SUNXI_MMC_RINT_END_BIT_ERROR) /* 0xbfc2 */ ++#define SUNXI_MMC_RINT_INTERRUPT_DONE_BIT \ ++ (SUNXI_MMC_RINT_AUTO_COMMAND_DONE | \ ++ SUNXI_MMC_RINT_DATA_OVER | \ ++ SUNXI_MMC_RINT_COMMAND_DONE | \ ++ SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE) ++ ++#define SUNXI_MMC_STATUS_RXWL_FLAG (0x1 << 0) ++#define SUNXI_MMC_STATUS_TXWL_FLAG (0x1 << 1) ++#define SUNXI_MMC_STATUS_FIFO_EMPTY (0x1 << 2) ++#define SUNXI_MMC_STATUS_FIFO_FULL (0x1 << 3) ++#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) ++ ++#define SUNXI_MMC_IDMAC_RESET (0x1 << 0) ++#define SUNXI_MMC_IDMAC_FIXBURST (0x1 << 1) ++#define SUNXI_MMC_IDMAC_ENABLE (0x1 << 7) ++ ++#define SUNXI_MMC_IDIE_TXIRQ (0x1 << 0) ++#define SUNXI_MMC_IDIE_RXIRQ (0x1 << 1) ++ ++#define SUNXI_MMC_COMMON_CLK_GATE (1 << 16) ++#define SUNXI_MMC_COMMON_RESET (1 << 18) ++ ++#define SUNXI_MMC_CAL_DL_SW_EN (0x1 << 7) ++ ++#endif /* _SUNXI_MMC_H */ diff --git a/package/boot/uboot-d1/patches/0020-pinctrl-sunxi-Add-support-for-the-D1.patch b/package/boot/uboot-d1/patches/0020-pinctrl-sunxi-Add-support-for-the-D1.patch new file mode 100644 index 00000000000000..383db83d171b59 --- /dev/null +++ b/package/boot/uboot-d1/patches/0020-pinctrl-sunxi-Add-support-for-the-D1.patch @@ -0,0 +1,72 @@ +From fdf871a6089ee2f56439880b69d33a7d0d707d15 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 28 Aug 2021 22:24:28 -0500 +Subject: [PATCH 20/90] pinctrl: sunxi: Add support for the D1 + +Signed-off-by: Samuel Holland +--- + drivers/pinctrl/sunxi/Kconfig | 5 +++++ + drivers/pinctrl/sunxi/pinctrl-sunxi.c | 31 +++++++++++++++++++++++++++ + 2 files changed, 36 insertions(+) + +--- a/drivers/pinctrl/sunxi/Kconfig ++++ b/drivers/pinctrl/sunxi/Kconfig +@@ -89,6 +89,11 @@ config PINCTRL_SUN9I_A80_R + default MACH_SUN9I + select PINCTRL_SUNXI + ++config PINCTRL_SUN20I_D1 ++ bool "Support for the Allwinner D1 PIO" ++ default TARGET_SUN20I_D1 ++ select PINCTRL_SUNXI ++ + config PINCTRL_SUN50I_A64 + bool "Support for the Allwinner A64 PIO" + default MACH_SUN50I +--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c ++++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c +@@ -588,6 +588,31 @@ static const struct sunxi_pinctrl_desc _ + .num_banks = 3, + }; + ++static const struct sunxi_pinctrl_function sun20i_d1_pinctrl_functions[] = { ++ { "emac", 8 }, /* PE0-PE15 */ ++ { "gpio_in", 0 }, ++ { "gpio_out", 1 }, ++ { "i2c0", 4 }, /* PB10-PB11 */ ++ { "mmc0", 2 }, /* PF0-PF5 */ ++ { "mmc1", 2 }, /* PG0-PG5 */ ++ { "mmc2", 3 }, /* PC2-PC7 */ ++ { "spi0", 2 }, /* PC2-PC7 */ ++#if IS_ENABLED(CONFIG_UART0_PORT_F) ++ { "uart0", 3 }, /* PF2-PF4 */ ++#else ++ { "uart0", 6 }, /* PB8-PB9 */ ++#endif ++ { "uart1", 2 }, /* PG6-PG7 */ ++ { "uart2", 7 }, /* PB0-PB1 */ ++}; ++ ++static const struct sunxi_pinctrl_desc __maybe_unused sun20i_d1_pinctrl_desc = { ++ .functions = sun20i_d1_pinctrl_functions, ++ .num_functions = ARRAY_SIZE(sun20i_d1_pinctrl_functions), ++ .first_bank = SUNXI_GPIO_A, ++ .num_banks = 7, ++}; ++ + static const struct sunxi_pinctrl_function sun50i_a64_pinctrl_functions[] = { + { "emac", 4 }, /* PD8-PD23 */ + { "gpio_in", 0 }, +@@ -849,6 +874,12 @@ static const struct udevice_id sunxi_pin + .data = (ulong)&sun9i_a80_r_pinctrl_desc, + }, + #endif ++#ifdef CONFIG_PINCTRL_SUN20I_D1 ++ { ++ .compatible = "allwinner,sun20i-d1-pinctrl", ++ .data = (ulong)&sun20i_d1_pinctrl_desc, ++ }, ++#endif + #ifdef CONFIG_PINCTRL_SUN50I_A64 + { + .compatible = "allwinner,sun50i-a64-pinctrl", diff --git a/package/boot/uboot-d1/patches/0021-serial-ns16550-Enable-clocks-during-probe.patch b/package/boot/uboot-d1/patches/0021-serial-ns16550-Enable-clocks-during-probe.patch new file mode 100644 index 00000000000000..0e28782287f0b2 --- /dev/null +++ b/package/boot/uboot-d1/patches/0021-serial-ns16550-Enable-clocks-during-probe.patch @@ -0,0 +1,34 @@ +From 8fde85b609273f8389178d4c0d066390a0e0773d Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 30 Oct 2022 14:56:10 -0500 +Subject: [PATCH 21/90] serial: ns16550: Enable clocks during probe + +If the UART bus or baud clock has a gate, it must be enabled before the +UART can be used. + +Signed-off-by: Samuel Holland +--- + drivers/serial/ns16550.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/serial/ns16550.c ++++ b/drivers/serial/ns16550.c +@@ -506,6 +506,7 @@ int ns16550_serial_probe(struct udevice + struct ns16550_plat *plat = dev_get_plat(dev); + struct ns16550 *const com_port = dev_get_priv(dev); + struct reset_ctl_bulk reset_bulk; ++ struct clk_bulk clk_bulk; + fdt_addr_t addr; + int ret; + +@@ -524,6 +525,10 @@ int ns16550_serial_probe(struct udevice + if (!ret) + reset_deassert_bulk(&reset_bulk); + ++ ret = clk_get_bulk(dev, &clk_bulk); ++ if (!ret) ++ clk_enable_bulk(&clk_bulk); ++ + com_port->plat = dev_get_plat(dev); + ns16550_init(com_port, -1); + diff --git a/package/boot/uboot-d1/patches/0022-fdt-Fix-bounds-check-in-devfdt_get_addr_index.patch b/package/boot/uboot-d1/patches/0022-fdt-Fix-bounds-check-in-devfdt_get_addr_index.patch new file mode 100644 index 00000000000000..88d4d670faf04a --- /dev/null +++ b/package/boot/uboot-d1/patches/0022-fdt-Fix-bounds-check-in-devfdt_get_addr_index.patch @@ -0,0 +1,28 @@ +From 0e4edc3a01f179337bb0bd0d31855dbce338a23e Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 30 Oct 2022 14:53:45 -0500 +Subject: [PATCH 22/90] fdt: Fix bounds check in devfdt_get_addr_index + +reg must contain enough cells for the entire next address/size pair +after skipping `index` pairs. The previous code allows an out-of-bounds +read when na + ns > 1. + +Series-to: Simon Glass + +Fixes: 69b41388ba45 ("dm: core: Add a new api to get indexed device address") +Signed-off-by: Samuel Holland +--- + drivers/core/fdtaddr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/core/fdtaddr.c ++++ b/drivers/core/fdtaddr.c +@@ -43,7 +43,7 @@ fdt_addr_t devfdt_get_addr_index(const s + } + + reg = fdt_getprop(gd->fdt_blob, offset, "reg", &len); +- if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) { ++ if (!reg || (len < ((index + 1) * sizeof(fdt32_t) * (na + ns)))) { + debug("Req index out of range\n"); + return FDT_ADDR_T_NONE; + } diff --git a/package/boot/uboot-d1/patches/0023-Kconfig-Remove-an-impossible-condition.patch b/package/boot/uboot-d1/patches/0023-Kconfig-Remove-an-impossible-condition.patch new file mode 100644 index 00000000000000..285fd1e04042a9 --- /dev/null +++ b/package/boot/uboot-d1/patches/0023-Kconfig-Remove-an-impossible-condition.patch @@ -0,0 +1,25 @@ +From 2d85df851c590b454749ac989a778bb226637bfc Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 15:08:39 +0000 +Subject: [PATCH 23/90] Kconfig: Remove an impossible condition + +ARCH_SUNXI selects BINMAN, so the condition "!BINMAN && ARCH_SUNXI" +is impossible to satisfy. + +Signed-off-by: Samuel Holland +Signed-off-by: Zoltan HERPAI +--- + Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/Kconfig ++++ b/Kconfig +@@ -459,7 +459,7 @@ config BUILD_TARGET + default "u-boot-with-spl.kwb" if ARCH_MVEBU && SPL + default "u-boot-elf.srec" if RCAR_GEN3 + default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \ +- ARCH_SUNXI || RISCV || ARCH_ZYNQMP) ++ RISCV || ARCH_ZYNQMP) + default "u-boot.kwb" if ARCH_KIRKWOOD + default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT + default "u-boot-with-spl.imx" if ARCH_MX6 && SPL diff --git a/package/boot/uboot-d1/patches/0024-binman-Prevent-entries-in-a-section-from-overlapping.patch b/package/boot/uboot-d1/patches/0024-binman-Prevent-entries-in-a-section-from-overlapping.patch new file mode 100644 index 00000000000000..2a7e544a7f4a6d --- /dev/null +++ b/package/boot/uboot-d1/patches/0024-binman-Prevent-entries-in-a-section-from-overlapping.patch @@ -0,0 +1,33 @@ +From b7150f7dd885012868c94b29ac4fe6152c065a95 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 10:43:56 -0500 +Subject: [PATCH 24/90] binman: Prevent entries in a section from overlapping + +Currently, if the "offset" property is given for an entry, the section's +running offset is completely ignored. This causes entries to overlap if +the provided offset is less than the size of the entries earlier in the +section. Avoid the overlap by only using the provided offset when it is +greater than the running offset. + +The motivation for this change is the rule used by SPL to find U-Boot on +sunxi boards: U-Boot starts 32 KiB after the start of SPL, unless SPL is +larger than 32 KiB, in which case U-Boot immediately follows SPL. + +Signed-off-by: Samuel Holland +--- + tools/binman/entry.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/tools/binman/entry.py ++++ b/tools/binman/entry.py +@@ -483,7 +483,9 @@ class Entry(object): + if self.offset_unset: + self.Raise('No offset set with offset-unset: should another ' + 'entry provide this correct offset?') +- self.offset = tools.align(offset, self.align) ++ elif self.offset > offset: ++ offset = self.offset ++ self.offset = tools.align(offset, self.align) + needed = self.pad_before + self.contents_size + self.pad_after + needed = tools.align(needed, self.align_size) + size = self.size diff --git a/package/boot/uboot-d1/patches/0025-sunxi-binman-Enable-SPL-FIT-loading-for-32-bit-SoCs.patch b/package/boot/uboot-d1/patches/0025-sunxi-binman-Enable-SPL-FIT-loading-for-32-bit-SoCs.patch new file mode 100644 index 00000000000000..7deee7a4691254 --- /dev/null +++ b/package/boot/uboot-d1/patches/0025-sunxi-binman-Enable-SPL-FIT-loading-for-32-bit-SoCs.patch @@ -0,0 +1,192 @@ +From b641ca5f4d272b83ef77ebcf5c75678cf139c69a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 17 Apr 2021 13:33:54 -0500 +Subject: [PATCH 25/90] sunxi: binman: Enable SPL FIT loading for 32-bit SoCs + +Now that Crust (SCP firmware) has support for H3, we need a FIT image to +load it. H3 also needs to load a SoC-specific eGon blob to support CPU 0 +hotplug. Let's first enable FIT support before adding extra firmware. + +Update the binman description to work on either 32-bit or 64-bit SoCs: + - Make BL31 optional, since it is not used on 32-bit SoCs (though BL32 + may be used in the future). + - Explicitly set the minimum offset of the FIT to 32 KiB, since SPL on + some boards is still only 24 KiB large even with FIT support enabled. + CONFIG_SPL_PAD_TO cannot be used because it is not defined for H616. + +FIT unlocks more features (signatures, multiple DTBs, etc.), so enable +it by default. A10 (sun4i) only has 24 KiB of SRAM A1, so it needs +SPL_FIT_IMAGE_TINY. For simplicity, enable that option everywhere. + +Cover-letter: +sunxi: SPL FIT support for 32-bit sunxi SoCs +This series makes the necessary changes so 32-bit sunxi SoCs can load +additional device trees or firmware from SPL along with U-Boot proper. + +There was no existing binman entry property that put the FIT at the +right offset. The minimum offset is 32k, but this matches neither the +SPL size (which is no more than 24k on some SoCs) nor the FIT alignment +(which is 512 bytes in practice due to SPL size constraints). So instead +of adding a new property, I fixed what is arguably a bug in the offset +property -- though this strategy will not work if someone is +intentionally creating overlapping entries. +END +Series-to: sunxi +Series-to: sjg +Signed-off-by: Samuel Holland +--- + arch/arm/Kconfig | 1 + + arch/arm/dts/sunxi-u-boot.dtsi | 46 ++++++++++++++++++++++------------ + common/spl/Kconfig | 9 +++---- + 3 files changed, 35 insertions(+), 21 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1135,6 +1135,7 @@ config ARCH_SUNXI + imply SPL_GPIO + imply SPL_LIBCOMMON_SUPPORT + imply SPL_LIBGENERIC_SUPPORT ++ imply SPL_LOAD_FIT + imply SPL_MMC if MMC + imply SPL_POWER + imply SPL_SERIAL +--- a/arch/arm/dts/sunxi-u-boot.dtsi ++++ b/arch/arm/dts/sunxi-u-boot.dtsi +@@ -1,13 +1,19 @@ + #include + +-#ifdef CONFIG_MACH_SUN50I_H6 +-#define BL31_ADDR 0x104000 +-#define SCP_ADDR 0x114000 +-#elif defined(CONFIG_MACH_SUN50I_H616) +-#define BL31_ADDR 0x40000000 ++#ifdef CONFIG_ARM64 ++#define ARCH "arm64" + #else +-#define BL31_ADDR 0x44000 +-#define SCP_ADDR 0x50000 ++#define ARCH "arm" ++#endif ++ ++#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5) ++#define BL31_ADDR 0x00044000 ++#define SCP_ADDR 0x00050000 ++#elif defined(CONFIG_MACH_SUN50I_H6) ++#define BL31_ADDR 0x00104000 ++#define SCP_ADDR 0x00114000 ++#elif defined(CONFIG_MACH_SUN50I_H616) ++#define BL31_ADDR 0x40000000 + #endif + + / { +@@ -34,30 +40,33 @@ + filename = "spl/sunxi-spl.bin"; + }; + +-#ifdef CONFIG_ARM64 ++#ifdef CONFIG_SPL_LOAD_FIT + fit { +- description = "Configuration to load ATF before U-Boot"; ++ description = "Configuration to load U-Boot and firmware"; ++ offset = <32768>; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + uboot { +- description = "U-Boot (64-bit)"; ++ description = "U-Boot"; + type = "standalone"; + os = "u-boot"; +- arch = "arm64"; ++ arch = ARCH; + compression = "none"; + load = ; ++ entry = ; + + u-boot-nodtb { + }; + }; + ++#ifdef BL31_ADDR + atf { + description = "ARM Trusted Firmware"; + type = "firmware"; + os = "arm-trusted-firmware"; +- arch = "arm64"; ++ arch = ARCH; + compression = "none"; + load = ; + entry = ; +@@ -67,6 +76,7 @@ + missing-msg = "atf-bl31-sunxi"; + }; + }; ++#endif + + #ifdef SCP_ADDR + scp { +@@ -95,19 +105,23 @@ + + @config-SEQ { + description = "NAME"; ++#ifdef BL31_ADDR + firmware = "atf"; +-#ifndef SCP_ADDR +- loadables = "uboot"; + #else +- loadables = "scp", "uboot"; ++ firmware = "uboot"; ++#endif ++ loadables = ++#ifdef SCP_ADDR ++ "scp", + #endif ++ "uboot"; + fdt = "fdt-SEQ"; + }; + }; + }; + #else + u-boot-img { +- offset = ; ++ offset = <32768>; + }; + #endif + }; +--- a/common/spl/Kconfig ++++ b/common/spl/Kconfig +@@ -76,12 +76,12 @@ config SPL_SIZE_LIMIT_PROVIDE_STACK + + config SPL_MAX_SIZE + hex "Maximum size of the SPL image, excluding BSS" ++ default 0x37fa0 if MACH_SUN50I_H616 + default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB ++ default 0x25fa0 if MACH_SUN50I_H6 + default 0x1b000 if AM33XX && !TI_SECURE_DEVICE + default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB + default 0x7fa0 if SUNXI_SRAM_ADDRESS = 0x10000 +- default 0x7fa0 if SUNXI_SRAM_ADDRESS = 0x20000 && !MACH_SUN50I_H616 +- default 0xbfa0 if MACH_SUN50I_H616 + default 0x7000 if RCAR_GEN3 + default 0x5fa0 if SUNXI_SRAM_ADDRESS = 0x0 + default 0x10000 if ASPEED_AST2600 +@@ -97,7 +97,7 @@ config SPL_PAD_TO + default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB + default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB) + default 0x10000 if ARCH_KEYSTONE +- default 0x8000 if ARCH_SUNXI && !MACH_SUN50I_H616 ++ default 0x0 if ARCH_SUNXI + default 0x0 if ARCH_MTMIPS + default TPL_MAX_SIZE if TPL_MAX_SIZE > SPL_MAX_SIZE + default SPL_MAX_SIZE +@@ -575,8 +575,7 @@ config SPL_MD5 + config SPL_FIT_IMAGE_TINY + bool "Remove functionality from SPL FIT loading to reduce size" + depends on SPL_FIT +- default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6 +- default y if ARCH_IMX8M || ARCH_IMX9 ++ default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI + help + Enable this to reduce the size of the FIT image loading code + in SPL, if space for the SPL binary is very tight. diff --git a/package/boot/uboot-d1/patches/0026-sunxi-psci-Avoid-hanging-when-CPU-0-is-hot-unplugged.patch b/package/boot/uboot-d1/patches/0026-sunxi-psci-Avoid-hanging-when-CPU-0-is-hot-unplugged.patch new file mode 100644 index 00000000000000..e440351b0abecc --- /dev/null +++ b/package/boot/uboot-d1/patches/0026-sunxi-psci-Avoid-hanging-when-CPU-0-is-hot-unplugged.patch @@ -0,0 +1,51 @@ +From ca1e6f4491981432c3e88441131c8e25067da95e Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 22:00:22 -0500 +Subject: [PATCH 26/90] sunxi: psci: Avoid hanging when CPU 0 is hot-unplugged + +Do not try to send an SGI from CPU 0 to itself. Since FIQs are masked +when entering monitor mode, this will hang. Plus, CPU 0 cannot fully +power itself off anyway. Instead, have it turn FIQs back on and continue +servicing SGIs from other cores. + +Signed-off-by: Samuel Holland +--- + arch/arm/cpu/armv7/sunxi/psci.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +--- a/arch/arm/cpu/armv7/sunxi/psci.c ++++ b/arch/arm/cpu/armv7/sunxi/psci.c +@@ -38,6 +38,15 @@ + #define SUN8I_R40_PWR_CLAMP(cpu) (0x120 + (cpu) * 0x4) + #define SUN8I_R40_SRAMC_SOFT_ENTRY_REG0 (0xbc) + ++static inline u32 __secure cp15_read_mpidr(void) ++{ ++ u32 val; ++ ++ asm volatile ("mrc p15, 0, %0, c0, c0, 5" : "=r" (val)); ++ ++ return val; ++} ++ + static void __secure cp15_write_cntp_tval(u32 tval) + { + asm volatile ("mcr p15, 0, %0, c14, c2, 0" : : "r" (tval)); +@@ -281,9 +290,14 @@ s32 __secure psci_cpu_off(void) + { + psci_cpu_off_common(); + +- /* Ask CPU0 via SGI15 to pull the rug... */ +- writel(BIT(16) | 15, GICD_BASE + GICD_SGIR); +- dsb(); ++ if (cp15_read_mpidr() & 3) { ++ /* Ask CPU0 via SGI15 to pull the rug... */ ++ writel(BIT(16) | 15, GICD_BASE + GICD_SGIR); ++ dsb(); ++ } else { ++ /* Unmask FIQs to service SGI15. */ ++ asm volatile ("cpsie f"); ++ } + + /* Wait to be turned off */ + while (1) diff --git a/package/boot/uboot-d1/patches/0027-clk-sunxi-Add-NAND-clocks-and-resets.patch b/package/boot/uboot-d1/patches/0027-clk-sunxi-Add-NAND-clocks-and-resets.patch new file mode 100644 index 00000000000000..157c3cd4a25309 --- /dev/null +++ b/package/boot/uboot-d1/patches/0027-clk-sunxi-Add-NAND-clocks-and-resets.patch @@ -0,0 +1,295 @@ +From 2f48dfc23d612f6f1798ff761854fd3141d0671f Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 15 May 2022 21:29:22 -0500 +Subject: [PATCH 27/90] clk: sunxi: Add NAND clocks and resets + +Currently NAND clock setup is done in board code, both in SPL and in +U-Boot proper. Add the NAND clocks/resets here so they can be used by +the "full" NAND driver once it is converted to the driver model. + +The bit locations are copied from the Linux CCU drivers. + +Signed-off-by: Samuel Holland +--- + drivers/clk/sunxi/clk_a10.c | 2 ++ + drivers/clk/sunxi/clk_a10s.c | 2 ++ + drivers/clk/sunxi/clk_a23.c | 3 +++ + drivers/clk/sunxi/clk_a31.c | 6 ++++++ + drivers/clk/sunxi/clk_a64.c | 3 +++ + drivers/clk/sunxi/clk_a80.c | 8 ++++++++ + drivers/clk/sunxi/clk_a83t.c | 3 +++ + drivers/clk/sunxi/clk_h3.c | 3 +++ + drivers/clk/sunxi/clk_h6.c | 6 ++++++ + drivers/clk/sunxi/clk_h616.c | 6 ++++++ + drivers/clk/sunxi/clk_r40.c | 3 +++ + 11 files changed, 45 insertions(+) + +--- a/drivers/clk/sunxi/clk_a10.c ++++ b/drivers/clk/sunxi/clk_a10.c +@@ -23,6 +23,7 @@ static struct ccu_clk_gate a10_gates[] = + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), + [CLK_AHB_MMC3] = GATE(0x060, BIT(11)), ++ [CLK_AHB_NAND] = GATE(0x060, BIT(13)), + [CLK_AHB_EMAC] = GATE(0x060, BIT(17)), + [CLK_AHB_SPI0] = GATE(0x060, BIT(20)), + [CLK_AHB_SPI1] = GATE(0x060, BIT(21)), +@@ -47,6 +48,7 @@ static struct ccu_clk_gate a10_gates[] = + [CLK_APB1_UART6] = GATE(0x06c, BIT(22)), + [CLK_APB1_UART7] = GATE(0x06c, BIT(23)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + [CLK_SPI2] = GATE(0x0a8, BIT(31)), +--- a/drivers/clk/sunxi/clk_a10s.c ++++ b/drivers/clk/sunxi/clk_a10s.c +@@ -20,6 +20,7 @@ static struct ccu_clk_gate a10s_gates[] + [CLK_AHB_MMC0] = GATE(0x060, BIT(8)), + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), ++ [CLK_AHB_NAND] = GATE(0x060, BIT(13)), + [CLK_AHB_EMAC] = GATE(0x060, BIT(17)), + [CLK_AHB_SPI0] = GATE(0x060, BIT(20)), + [CLK_AHB_SPI1] = GATE(0x060, BIT(21)), +@@ -35,6 +36,7 @@ static struct ccu_clk_gate a10s_gates[] + [CLK_APB1_UART2] = GATE(0x06c, BIT(18)), + [CLK_APB1_UART3] = GATE(0x06c, BIT(19)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + [CLK_SPI2] = GATE(0x0a8, BIT(31)), +--- a/drivers/clk/sunxi/clk_a23.c ++++ b/drivers/clk/sunxi/clk_a23.c +@@ -17,6 +17,7 @@ static struct ccu_clk_gate a23_gates[] = + [CLK_BUS_MMC0] = GATE(0x060, BIT(8)), + [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), + [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), ++ [CLK_BUS_NAND] = GATE(0x060, BIT(13)), + [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x060, BIT(21)), + [CLK_BUS_OTG] = GATE(0x060, BIT(24)), +@@ -34,6 +35,7 @@ static struct ccu_clk_gate a23_gates[] = + [CLK_BUS_UART3] = GATE(0x06c, BIT(19)), + [CLK_BUS_UART4] = GATE(0x06c, BIT(20)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + +@@ -52,6 +54,7 @@ static struct ccu_reset a23_resets[] = { + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), ++ [RST_BUS_NAND] = RESET(0x2c0, BIT(13)), + [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x2c0, BIT(21)), + [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), +--- a/drivers/clk/sunxi/clk_a31.c ++++ b/drivers/clk/sunxi/clk_a31.c +@@ -18,6 +18,8 @@ static struct ccu_clk_gate a31_gates[] = + [CLK_AHB1_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB1_MMC2] = GATE(0x060, BIT(10)), + [CLK_AHB1_MMC3] = GATE(0x060, BIT(11)), ++ [CLK_AHB1_NAND1] = GATE(0x060, BIT(12)), ++ [CLK_AHB1_NAND0] = GATE(0x060, BIT(13)), + [CLK_AHB1_EMAC] = GATE(0x060, BIT(17)), + [CLK_AHB1_SPI0] = GATE(0x060, BIT(20)), + [CLK_AHB1_SPI1] = GATE(0x060, BIT(21)), +@@ -43,6 +45,8 @@ static struct ccu_clk_gate a31_gates[] = + [CLK_APB2_UART4] = GATE(0x06c, BIT(20)), + [CLK_APB2_UART5] = GATE(0x06c, BIT(21)), + ++ [CLK_NAND0] = GATE(0x080, BIT(31)), ++ [CLK_NAND1] = GATE(0x084, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + [CLK_SPI2] = GATE(0x0a8, BIT(31)), +@@ -65,6 +69,8 @@ static struct ccu_reset a31_resets[] = { + [RST_AHB1_MMC1] = RESET(0x2c0, BIT(9)), + [RST_AHB1_MMC2] = RESET(0x2c0, BIT(10)), + [RST_AHB1_MMC3] = RESET(0x2c0, BIT(11)), ++ [RST_AHB1_NAND1] = RESET(0x2c0, BIT(12)), ++ [RST_AHB1_NAND0] = RESET(0x2c0, BIT(13)), + [RST_AHB1_EMAC] = RESET(0x2c0, BIT(17)), + [RST_AHB1_SPI0] = RESET(0x2c0, BIT(20)), + [RST_AHB1_SPI1] = RESET(0x2c0, BIT(21)), +--- a/drivers/clk/sunxi/clk_a64.c ++++ b/drivers/clk/sunxi/clk_a64.c +@@ -19,6 +19,7 @@ static const struct ccu_clk_gate a64_gat + [CLK_BUS_MMC0] = GATE(0x060, BIT(8)), + [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), + [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), ++ [CLK_BUS_NAND] = GATE(0x060, BIT(13)), + [CLK_BUS_EMAC] = GATE(0x060, BIT(17)), + [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x060, BIT(21)), +@@ -39,6 +40,7 @@ static const struct ccu_clk_gate a64_gat + [CLK_BUS_UART3] = GATE(0x06c, BIT(19)), + [CLK_BUS_UART4] = GATE(0x06c, BIT(20)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + +@@ -58,6 +60,7 @@ static const struct ccu_reset a64_resets + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), ++ [RST_BUS_NAND] = RESET(0x2c0, BIT(13)), + [RST_BUS_EMAC] = RESET(0x2c0, BIT(17)), + [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x2c0, BIT(21)), +--- a/drivers/clk/sunxi/clk_a80.c ++++ b/drivers/clk/sunxi/clk_a80.c +@@ -14,12 +14,18 @@ + #include + + static const struct ccu_clk_gate a80_gates[] = { ++ [CLK_NAND0_0] = GATE(0x400, BIT(31)), ++ [CLK_NAND0_1] = GATE(0x404, BIT(31)), ++ [CLK_NAND1_0] = GATE(0x408, BIT(31)), ++ [CLK_NAND1_1] = GATE(0x40c, BIT(31)), + [CLK_SPI0] = GATE(0x430, BIT(31)), + [CLK_SPI1] = GATE(0x434, BIT(31)), + [CLK_SPI2] = GATE(0x438, BIT(31)), + [CLK_SPI3] = GATE(0x43c, BIT(31)), + + [CLK_BUS_MMC] = GATE(0x580, BIT(8)), ++ [CLK_BUS_NAND0] = GATE(0x580, BIT(12)), ++ [CLK_BUS_NAND1] = GATE(0x580, BIT(13)), + [CLK_BUS_SPI0] = GATE(0x580, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x580, BIT(21)), + [CLK_BUS_SPI2] = GATE(0x580, BIT(22)), +@@ -42,6 +48,8 @@ static const struct ccu_clk_gate a80_gat + + static const struct ccu_reset a80_resets[] = { + [RST_BUS_MMC] = RESET(0x5a0, BIT(8)), ++ [RST_BUS_NAND0] = RESET(0x5a0, BIT(12)), ++ [RST_BUS_NAND1] = RESET(0x5a0, BIT(13)), + [RST_BUS_SPI0] = RESET(0x5a0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x5a0, BIT(21)), + [RST_BUS_SPI2] = RESET(0x5a0, BIT(22)), +--- a/drivers/clk/sunxi/clk_a83t.c ++++ b/drivers/clk/sunxi/clk_a83t.c +@@ -17,6 +17,7 @@ static struct ccu_clk_gate a83t_gates[] + [CLK_BUS_MMC0] = GATE(0x060, BIT(8)), + [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), + [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), ++ [CLK_BUS_NAND] = GATE(0x060, BIT(13)), + [CLK_BUS_EMAC] = GATE(0x060, BIT(17)), + [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x060, BIT(21)), +@@ -36,6 +37,7 @@ static struct ccu_clk_gate a83t_gates[] + [CLK_BUS_UART3] = GATE(0x06c, BIT(19)), + [CLK_BUS_UART4] = GATE(0x06c, BIT(20)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + +@@ -54,6 +56,7 @@ static struct ccu_reset a83t_resets[] = + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), ++ [RST_BUS_NAND] = RESET(0x2c0, BIT(13)), + [RST_BUS_EMAC] = RESET(0x2c0, BIT(17)), + [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x2c0, BIT(21)), +--- a/drivers/clk/sunxi/clk_h3.c ++++ b/drivers/clk/sunxi/clk_h3.c +@@ -19,6 +19,7 @@ static struct ccu_clk_gate h3_gates[] = + [CLK_BUS_MMC0] = GATE(0x060, BIT(8)), + [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), + [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), ++ [CLK_BUS_NAND] = GATE(0x060, BIT(13)), + [CLK_BUS_EMAC] = GATE(0x060, BIT(17)), + [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x060, BIT(21)), +@@ -44,6 +45,7 @@ static struct ccu_clk_gate h3_gates[] = + + [CLK_BUS_EPHY] = GATE(0x070, BIT(0)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + +@@ -66,6 +68,7 @@ static struct ccu_reset h3_resets[] = { + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), ++ [RST_BUS_NAND] = RESET(0x2c0, BIT(13)), + [RST_BUS_EMAC] = RESET(0x2c0, BIT(17)), + [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x2c0, BIT(21)), +--- a/drivers/clk/sunxi/clk_h6.c ++++ b/drivers/clk/sunxi/clk_h6.c +@@ -18,6 +18,10 @@ static struct ccu_clk_gate h6_gates[] = + + [CLK_APB1] = GATE_DUMMY, + ++ [CLK_NAND0] = GATE(0x810, BIT(31)), ++ [CLK_NAND1] = GATE(0x814, BIT(31)), ++ [CLK_BUS_NAND] = GATE(0x82c, BIT(0)), ++ + [CLK_BUS_MMC0] = GATE(0x84c, BIT(0)), + [CLK_BUS_MMC1] = GATE(0x84c, BIT(1)), + [CLK_BUS_MMC2] = GATE(0x84c, BIT(2)), +@@ -58,6 +62,8 @@ static struct ccu_clk_gate h6_gates[] = + }; + + static struct ccu_reset h6_resets[] = { ++ [RST_BUS_NAND] = RESET(0x82c, BIT(16)), ++ + [RST_BUS_MMC0] = RESET(0x84c, BIT(16)), + [RST_BUS_MMC1] = RESET(0x84c, BIT(17)), + [RST_BUS_MMC2] = RESET(0x84c, BIT(18)), +--- a/drivers/clk/sunxi/clk_h616.c ++++ b/drivers/clk/sunxi/clk_h616.c +@@ -17,6 +17,10 @@ static struct ccu_clk_gate h616_gates[] + + [CLK_APB1] = GATE_DUMMY, + ++ [CLK_NAND0] = GATE(0x810, BIT(31)), ++ [CLK_NAND1] = GATE(0x814, BIT(31)), ++ [CLK_BUS_NAND] = GATE(0x82c, BIT(0)), ++ + [CLK_BUS_MMC0] = GATE(0x84c, BIT(0)), + [CLK_BUS_MMC1] = GATE(0x84c, BIT(1)), + [CLK_BUS_MMC2] = GATE(0x84c, BIT(2)), +@@ -67,6 +71,8 @@ static struct ccu_clk_gate h616_gates[] + }; + + static struct ccu_reset h616_resets[] = { ++ [RST_BUS_NAND] = RESET(0x82c, BIT(16)), ++ + [RST_BUS_MMC0] = RESET(0x84c, BIT(16)), + [RST_BUS_MMC1] = RESET(0x84c, BIT(17)), + [RST_BUS_MMC2] = RESET(0x84c, BIT(18)), +--- a/drivers/clk/sunxi/clk_r40.c ++++ b/drivers/clk/sunxi/clk_r40.c +@@ -18,6 +18,7 @@ static struct ccu_clk_gate r40_gates[] = + [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), + [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), + [CLK_BUS_MMC3] = GATE(0x060, BIT(11)), ++ [CLK_BUS_NAND] = GATE(0x060, BIT(13)), + [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), + [CLK_BUS_SPI1] = GATE(0x060, BIT(21)), + [CLK_BUS_SPI2] = GATE(0x060, BIT(22)), +@@ -48,6 +49,7 @@ static struct ccu_clk_gate r40_gates[] = + [CLK_BUS_UART6] = GATE(0x06c, BIT(22)), + [CLK_BUS_UART7] = GATE(0x06c, BIT(23)), + ++ [CLK_NAND] = GATE(0x080, BIT(31)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_SPI1] = GATE(0x0a4, BIT(31)), + [CLK_SPI2] = GATE(0x0a8, BIT(31)), +@@ -70,6 +72,7 @@ static struct ccu_reset r40_resets[] = { + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), + [RST_BUS_MMC3] = RESET(0x2c0, BIT(11)), ++ [RST_BUS_NAND] = RESET(0x2c0, BIT(13)), + [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), + [RST_BUS_SPI1] = RESET(0x2c0, BIT(21)), + [RST_BUS_SPI2] = RESET(0x2c0, BIT(22)), diff --git a/package/boot/uboot-d1/patches/0028-pinctrl-sunxi-Add-NAND-pinmuxes.patch b/package/boot/uboot-d1/patches/0028-pinctrl-sunxi-Add-NAND-pinmuxes.patch new file mode 100644 index 00000000000000..6ecba35890db80 --- /dev/null +++ b/package/boot/uboot-d1/patches/0028-pinctrl-sunxi-Add-NAND-pinmuxes.patch @@ -0,0 +1,120 @@ +From 7be2405244565973cff0a40196bbed08df90f6a3 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 16 May 2022 00:31:36 -0500 +Subject: [PATCH 28/90] pinctrl: sunxi: Add NAND pinmuxes + +NAND is always at function 2 on port C. + +Pin lists and mux values were taken from the Linux drivers. + +Signed-off-by: Samuel Holland +--- + drivers/pinctrl/sunxi/pinctrl-sunxi.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c ++++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c +@@ -269,6 +269,7 @@ static const struct sunxi_pinctrl_functi + #endif + { "mmc2", 3 }, /* PC6-PC15 */ + { "mmc3", 2 }, /* PI4-PI9 */ ++ { "nand0", 2 }, /* PC0-PC24 */ + { "spi0", 3 }, /* PC0-PC2, PC23 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 4 }, /* PF2-PF4 */ +@@ -293,6 +294,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG3-PG8 */ + { "mmc2", 3 }, /* PC6-PC15 */ ++ { "nand0", 2 }, /* PC0-PC19 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 4 }, /* PF2-PF4 */ +@@ -319,6 +321,7 @@ static const struct sunxi_pinctrl_functi + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC6-PC15, PC24 */ + { "mmc3", 4 }, /* PC6-PC15, PC24 */ ++ { "nand0", 2 }, /* PC0-PC26 */ + { "spi0", 3 }, /* PC0-PC2, PC27 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -363,6 +366,7 @@ static const struct sunxi_pinctrl_functi + { "mmc1", 4 }, /* PG0-PG5 */ + #endif + { "mmc2", 3 }, /* PC5-PC15, PC24 */ ++ { "nand0", 2 }, /* PC0-PC24 */ + { "spi0", 3 }, /* PC0-PC2, PC23 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 4 }, /* PF2-PF4 */ +@@ -386,6 +390,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC5-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -424,6 +429,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC5-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -450,6 +456,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC5-PC16 */ ++ { "nand0", 2 }, /* PC0-PC18 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -491,6 +498,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC5-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -557,6 +565,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC6-PC16 */ ++ { "nand0", 2 }, /* PC0-PC18 */ + { "spi0", 3 }, /* PC0-PC2, PC19 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 4 }, /* PF2-PF4 */ +@@ -622,6 +631,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC1-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "pwm", 2 }, /* PD22 */ + { "spi0", 4 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) +@@ -664,6 +674,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC1-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 3 }, /* PC0-PC3 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -690,6 +701,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC1-PC14 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 4 }, /* PC0-PC7 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ +@@ -728,6 +740,7 @@ static const struct sunxi_pinctrl_functi + { "mmc0", 2 }, /* PF0-PF5 */ + { "mmc1", 2 }, /* PG0-PG5 */ + { "mmc2", 3 }, /* PC0-PC16 */ ++ { "nand0", 2 }, /* PC0-PC16 */ + { "spi0", 4 }, /* PC0-PC7, PC15-PC16 */ + #if IS_ENABLED(CONFIG_UART0_PORT_F) + { "uart0", 3 }, /* PF2-PF4 */ diff --git a/package/boot/uboot-d1/patches/0029-mtd-nand-sunxi-Remove-an-unnecessary-check.patch b/package/boot/uboot-d1/patches/0029-mtd-nand-sunxi-Remove-an-unnecessary-check.patch new file mode 100644 index 00000000000000..807c31d922fad1 --- /dev/null +++ b/package/boot/uboot-d1/patches/0029-mtd-nand-sunxi-Remove-an-unnecessary-check.patch @@ -0,0 +1,32 @@ +From 8e793af8598a8429c9dc0f096c72a92adb360a57 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 15 May 2022 21:51:47 -0500 +Subject: [PATCH 29/90] mtd: nand: sunxi: Remove an unnecessary check + +Each chip is required to have a unique CS number ("reg" property) in the +range 0-7, so there is no need to separately count the number of chips. + +Signed-off-by: Samuel Holland +--- + drivers/mtd/nand/raw/sunxi_nand.c | 10 ---------- + 1 file changed, 10 deletions(-) + +--- a/drivers/mtd/nand/raw/sunxi_nand.c ++++ b/drivers/mtd/nand/raw/sunxi_nand.c +@@ -1767,16 +1767,6 @@ static int sunxi_nand_chips_init(int nod + int ret, i = 0; + + for (nand_node = fdt_first_subnode(blob, node); nand_node >= 0; +- nand_node = fdt_next_subnode(blob, nand_node)) +- i++; +- +- if (i > 8) { +- dev_err(nfc->dev, "too many NAND chips: %d (max = 8)\n", i); +- return -EINVAL; +- } +- +- i = 0; +- for (nand_node = fdt_first_subnode(blob, node); nand_node >= 0; + nand_node = fdt_next_subnode(blob, nand_node)) { + ret = sunxi_nand_chip_init(nand_node, nfc, i++); + if (ret) diff --git a/package/boot/uboot-d1/patches/0030-mtd-nand-sunxi-Convert-from-fdtdec-to-ofnode.patch b/package/boot/uboot-d1/patches/0030-mtd-nand-sunxi-Convert-from-fdtdec-to-ofnode.patch new file mode 100644 index 00000000000000..c88fef4f966d9a --- /dev/null +++ b/package/boot/uboot-d1/patches/0030-mtd-nand-sunxi-Convert-from-fdtdec-to-ofnode.patch @@ -0,0 +1,203 @@ +From 61b63cbb3526e19a0e299f95a3435a237c7c4b4b Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 15 May 2022 21:54:25 -0500 +Subject: [PATCH 30/90] mtd: nand: sunxi: Convert from fdtdec to ofnode + +As a first step toward converting this driver to the driver model, use +the ofnode abstraction to replace direct references to the FDT blob. + +Using ofnode_read_u32_index removes an extra pair of loops and makes the +allwinner,rb property optional, matching the devicetree binding. + +Signed-off-by: Samuel Holland +--- + drivers/mtd/nand/raw/sunxi_nand.c | 73 +++++++++++-------------------- + include/fdtdec.h | 1 - + lib/fdtdec.c | 1 - + 3 files changed, 26 insertions(+), 49 deletions(-) + +--- a/drivers/mtd/nand/raw/sunxi_nand.c ++++ b/drivers/mtd/nand/raw/sunxi_nand.c +@@ -25,11 +25,10 @@ + */ + + #include +-#include ++#include + #include + #include + #include +-#include + #include + #include + #include +@@ -45,8 +44,6 @@ + #include + #include + +-DECLARE_GLOBAL_DATA_PTR; +- + #define NFC_REG_CTL 0x0000 + #define NFC_REG_ST 0x0004 + #define NFC_REG_INT 0x0008 +@@ -1605,19 +1602,18 @@ static int sunxi_nand_ecc_init(struct mt + return 0; + } + +-static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum) ++static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) + { + const struct nand_sdr_timings *timings; +- const void *blob = gd->fdt_blob; + struct sunxi_nand_chip *chip; + struct mtd_info *mtd; + struct nand_chip *nand; + int nsels; + int ret; + int i; +- u32 cs[8], rb[8]; ++ u32 tmp; + +- if (!fdt_getprop(blob, node, "reg", &nsels)) ++ if (!ofnode_get_property(np, "reg", &nsels)) + return -EINVAL; + + nsels /= sizeof(u32); +@@ -1638,25 +1634,12 @@ static int sunxi_nand_chip_init(int node + chip->selected = -1; + + for (i = 0; i < nsels; i++) { +- cs[i] = -1; +- rb[i] = -1; +- } +- +- ret = fdtdec_get_int_array(gd->fdt_blob, node, "reg", cs, nsels); +- if (ret) { +- dev_err(nfc->dev, "could not retrieve reg property: %d\n", ret); +- return ret; +- } +- +- ret = fdtdec_get_int_array(gd->fdt_blob, node, "allwinner,rb", rb, +- nsels); +- if (ret) { +- dev_err(nfc->dev, "could not retrieve reg property: %d\n", ret); +- return ret; +- } +- +- for (i = 0; i < nsels; i++) { +- int tmp = cs[i]; ++ ret = ofnode_read_u32_index(np, "reg", i, &tmp); ++ if (ret) { ++ dev_err(nfc->dev, "could not retrieve reg property: %d\n", ++ ret); ++ return ret; ++ } + + if (tmp > NFC_MAX_CS) { + dev_err(nfc->dev, +@@ -1671,15 +1654,14 @@ static int sunxi_nand_chip_init(int node + + chip->sels[i].cs = tmp; + +- tmp = rb[i]; +- if (tmp >= 0 && tmp < 2) { ++ if (!ofnode_read_u32_index(np, "allwinner,rb", i, &tmp) && ++ tmp < 2) { + chip->sels[i].rb.type = RB_NATIVE; + chip->sels[i].rb.info.nativeid = tmp; + } else { +- ret = gpio_request_by_name_nodev(offset_to_ofnode(node), +- "rb-gpios", i, +- &chip->sels[i].rb.info.gpio, +- GPIOD_IS_IN); ++ ret = gpio_request_by_name_nodev(np, "rb-gpios", i, ++ &chip->sels[i].rb.info.gpio, ++ GPIOD_IS_IN); + if (ret) + chip->sels[i].rb.type = RB_GPIO; + else +@@ -1711,7 +1693,7 @@ static int sunxi_nand_chip_init(int node + * in the DT. + */ + nand->ecc.mode = NAND_ECC_HW; +- nand->flash_node = offset_to_ofnode(node); ++ nand->flash_node = np; + nand->select_chip = sunxi_nfc_select_chip; + nand->cmd_ctrl = sunxi_nfc_cmd_ctrl; + nand->read_buf = sunxi_nfc_read_buf; +@@ -1760,15 +1742,13 @@ static int sunxi_nand_chip_init(int node + return 0; + } + +-static int sunxi_nand_chips_init(int node, struct sunxi_nfc *nfc) ++static int sunxi_nand_chips_init(ofnode node, struct sunxi_nfc *nfc) + { +- const void *blob = gd->fdt_blob; +- int nand_node; ++ ofnode nand_np; + int ret, i = 0; + +- for (nand_node = fdt_first_subnode(blob, node); nand_node >= 0; +- nand_node = fdt_next_subnode(blob, nand_node)) { +- ret = sunxi_nand_chip_init(nand_node, nfc, i++); ++ ofnode_for_each_subnode(nand_np, node) { ++ ret = sunxi_nand_chip_init(nand_np, nfc, i++); + if (ret) + return ret; + } +@@ -1794,10 +1774,9 @@ static void sunxi_nand_chips_cleanup(str + + void sunxi_nand_init(void) + { +- const void *blob = gd->fdt_blob; + struct sunxi_nfc *nfc; +- fdt_addr_t regs; +- int node; ++ phys_addr_t regs; ++ ofnode node; + int ret; + + nfc = kzalloc(sizeof(*nfc), GFP_KERNEL); +@@ -1808,18 +1787,18 @@ void sunxi_nand_init(void) + init_waitqueue_head(&nfc->controller.wq); + INIT_LIST_HEAD(&nfc->chips); + +- node = fdtdec_next_compatible(blob, 0, COMPAT_SUNXI_NAND); +- if (node < 0) { ++ node = ofnode_by_compatible(ofnode_null(), "allwinner,sun4i-a10-nand"); ++ if (!ofnode_valid(node)) { + pr_err("unable to find nfc node in device tree\n"); + goto err; + } + +- if (!fdtdec_get_is_enabled(blob, node)) { ++ if (!ofnode_is_enabled(node)) { + pr_err("nfc disabled in device tree\n"); + goto err; + } + +- regs = fdtdec_get_addr(blob, node, "reg"); ++ regs = ofnode_get_addr(node); + if (regs == FDT_ADDR_T_NONE) { + pr_err("unable to find nfc address in device tree\n"); + goto err; +--- a/include/fdtdec.h ++++ b/include/fdtdec.h +@@ -187,7 +187,6 @@ enum fdt_compat_id { + COMPAT_INTEL_BAYTRAIL_FSP, /* Intel Bay Trail FSP */ + COMPAT_INTEL_BAYTRAIL_FSP_MDP, /* Intel FSP memory-down params */ + COMPAT_INTEL_IVYBRIDGE_FSP, /* Intel Ivy Bridge FSP */ +- COMPAT_SUNXI_NAND, /* SUNXI NAND controller */ + COMPAT_ALTERA_SOCFPGA_CLK, /* SoCFPGA Clock initialization */ + COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE, /* SoCFPGA pinctrl-single */ + COMPAT_ALTERA_SOCFPGA_H2F_BRG, /* SoCFPGA hps2fpga bridge */ +--- a/lib/fdtdec.c ++++ b/lib/fdtdec.c +@@ -64,7 +64,6 @@ static const char * const compat_names[C + COMPAT(INTEL_BAYTRAIL_FSP, "intel,baytrail-fsp"), + COMPAT(INTEL_BAYTRAIL_FSP_MDP, "intel,baytrail-fsp-mdp"), + COMPAT(INTEL_IVYBRIDGE_FSP, "intel,ivybridge-fsp"), +- COMPAT(COMPAT_SUNXI_NAND, "allwinner,sun4i-a10-nand"), + COMPAT(ALTERA_SOCFPGA_CLK, "altr,clk-mgr"), + COMPAT(ALTERA_SOCFPGA_PINCTRL_SINGLE, "pinctrl-single"), + COMPAT(ALTERA_SOCFPGA_H2F_BRG, "altr,socfpga-hps2fpga-bridge"), diff --git a/package/boot/uboot-d1/patches/0031-mtd-nand-sunxi-Convert-to-the-driver-model.patch b/package/boot/uboot-d1/patches/0031-mtd-nand-sunxi-Convert-to-the-driver-model.patch new file mode 100644 index 00000000000000..d1bec458af6540 --- /dev/null +++ b/package/boot/uboot-d1/patches/0031-mtd-nand-sunxi-Convert-to-the-driver-model.patch @@ -0,0 +1,172 @@ +From 3411a9a1be9a8d8fef236a81edbce2a1a8218a32 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 16 May 2022 00:16:48 -0500 +Subject: [PATCH 31/90] mtd: nand: sunxi: Convert to the driver model + +Clocks, resets, and pinmuxes are now handled by the driver model, so the +only thing the "board" code needs to do is load the driver. This matches +the pattern used by other DM raw NAND drivers (there is no NAND uclass). + +The actual board code is now only needed in SPL. + +Signed-off-by: Samuel Holland +--- + board/sunxi/board.c | 5 +- + drivers/mtd/nand/raw/sunxi_nand.c | 81 ++++++++++++++++++------------- + 2 files changed, 49 insertions(+), 37 deletions(-) + +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -311,7 +311,7 @@ int dram_init(void) + return 0; + } + +-#if defined(CONFIG_NAND_SUNXI) ++#if defined(CONFIG_NAND_SUNXI) && defined(CONFIG_SPL_BUILD) + static void nand_pinmux_setup(void) + { + unsigned int pin; +@@ -347,9 +347,6 @@ void board_nand_init(void) + { + nand_pinmux_setup(); + nand_clock_setup(); +-#ifndef CONFIG_SPL_BUILD +- sunxi_nand_init(); +-#endif + } + #endif /* CONFIG_NAND_SUNXI */ + +--- a/drivers/mtd/nand/raw/sunxi_nand.c ++++ b/drivers/mtd/nand/raw/sunxi_nand.c +@@ -24,11 +24,13 @@ + * GNU General Public License for more details. + */ + ++#include + #include + #include + #include + #include + #include ++#include + #include + #include + #include +@@ -260,7 +262,7 @@ static inline struct sunxi_nand_chip *to + * NAND Controller structure: stores sunxi NAND controller information + * + * @controller: base controller structure +- * @dev: parent device (used to print error messages) ++ * @dev: DM device (used to print error messages) + * @regs: NAND controller registers + * @ahb_clk: NAND Controller AHB clock + * @mod_clk: NAND Controller mod clock +@@ -273,7 +275,7 @@ static inline struct sunxi_nand_chip *to + */ + struct sunxi_nfc { + struct nand_hw_control controller; +- struct device *dev; ++ struct udevice *dev; + void __iomem *regs; + struct clk *ahb_clk; + struct clk *mod_clk; +@@ -1772,54 +1774,67 @@ static void sunxi_nand_chips_cleanup(str + } + #endif /* __UBOOT__ */ + +-void sunxi_nand_init(void) ++static int sunxi_nand_probe(struct udevice *dev) + { +- struct sunxi_nfc *nfc; +- phys_addr_t regs; +- ofnode node; ++ struct sunxi_nfc *nfc = dev_get_priv(dev); ++ struct reset_ctl_bulk rst_bulk; ++ struct clk_bulk clk_bulk; + int ret; + +- nfc = kzalloc(sizeof(*nfc), GFP_KERNEL); +- if (!nfc) +- return; +- ++ nfc->dev = dev; + spin_lock_init(&nfc->controller.lock); + init_waitqueue_head(&nfc->controller.wq); + INIT_LIST_HEAD(&nfc->chips); + +- node = ofnode_by_compatible(ofnode_null(), "allwinner,sun4i-a10-nand"); +- if (!ofnode_valid(node)) { +- pr_err("unable to find nfc node in device tree\n"); +- goto err; +- } +- +- if (!ofnode_is_enabled(node)) { +- pr_err("nfc disabled in device tree\n"); +- goto err; +- } +- +- regs = ofnode_get_addr(node); +- if (regs == FDT_ADDR_T_NONE) { +- pr_err("unable to find nfc address in device tree\n"); +- goto err; +- } ++ nfc->regs = dev_read_addr_ptr(dev); ++ if (!nfc->regs) ++ return -EINVAL; + +- nfc->regs = (void *)regs; ++ ret = reset_get_bulk(dev, &rst_bulk); ++ if (!ret) ++ reset_deassert_bulk(&rst_bulk); ++ ++ ret = clk_get_bulk(dev, &clk_bulk); ++ if (!ret) ++ clk_enable_bulk(&clk_bulk); + + ret = sunxi_nfc_rst(nfc); + if (ret) +- goto err; ++ return ret; + +- ret = sunxi_nand_chips_init(node, nfc); ++ ret = sunxi_nand_chips_init(dev_ofnode(dev), nfc); + if (ret) { +- dev_err(nfc->dev, "failed to init nand chips\n"); +- goto err; ++ dev_err(dev, "failed to init nand chips\n"); ++ return ret; + } + +- return; ++ return 0; ++} + +-err: +- kfree(nfc); ++static const struct udevice_id sunxi_nand_ids[] = { ++ { ++ .compatible = "allwinner,sun4i-a10-nand", ++ }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sunxi_nand) = { ++ .name = "sunxi_nand", ++ .id = UCLASS_MTD, ++ .of_match = sunxi_nand_ids, ++ .probe = sunxi_nand_probe, ++ .priv_auto = sizeof(struct sunxi_nfc), ++}; ++ ++void board_nand_init(void) ++{ ++ struct udevice *dev; ++ int ret; ++ ++ ret = uclass_get_device_by_driver(UCLASS_MTD, ++ DM_DRIVER_GET(sunxi_nand), &dev); ++ if (ret && ret != -ENODEV) ++ pr_err("Failed to initialize sunxi NAND controller: %d\n", ret); + } + + MODULE_LICENSE("GPL v2"); diff --git a/package/boot/uboot-d1/patches/0032-sunxi-DT-H6-Add-USB3-to-Pine-H64-DTS.patch b/package/boot/uboot-d1/patches/0032-sunxi-DT-H6-Add-USB3-to-Pine-H64-DTS.patch new file mode 100644 index 00000000000000..87c9da924ceb42 --- /dev/null +++ b/package/boot/uboot-d1/patches/0032-sunxi-DT-H6-Add-USB3-to-Pine-H64-DTS.patch @@ -0,0 +1,31 @@ +From 6fdd7e8d2758f69f5c8e3cb2a0f06da47c1f2cb4 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 17 Apr 2021 14:21:45 -0500 +Subject: [PATCH 32/90] sunxi: DT: H6: Add USB3 to Pine H64 DTS + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/sun50i-h6-pine-h64.dts | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/arch/arm/dts/sun50i-h6-pine-h64.dts ++++ b/arch/arm/dts/sun50i-h6-pine-h64.dts +@@ -89,6 +89,10 @@ + status = "okay"; + }; + ++&dwc3 { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -332,3 +336,7 @@ + usb3_vbus-supply = <®_usb_vbus>; + status = "okay"; + }; ++ ++&usb3phy { ++ status = "okay"; ++}; diff --git a/package/boot/uboot-d1/patches/0033-tools-mkimage-Add-Allwinner-TOC1-support.patch b/package/boot/uboot-d1/patches/0033-tools-mkimage-Add-Allwinner-TOC1-support.patch new file mode 100644 index 00000000000000..d443cdf36987a9 --- /dev/null +++ b/package/boot/uboot-d1/patches/0033-tools-mkimage-Add-Allwinner-TOC1-support.patch @@ -0,0 +1,441 @@ +From ff0e952a3a380ba191375d5f68609cdbe026d535 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 7 Aug 2021 19:55:20 -0500 +Subject: [PATCH 33/90] tools: mkimage: Add Allwinner TOC1 support + +TOC1 is an container format used by Allwinner's boot0 that can hold +multiple images. It supports encryption and signatures, but that +functionality is not implemented, only the basic "non-secure" subset. + +A config file is used to provide the list of data files to include. Its +path is passed as the argument to "-d". It contains sections of the +following form: + + [name] + file = /path/to/file + addr = 0x12345678 + +Specific well-known names, such as "dtb", "opensbi", and "u-boot", are +used by the bootloader to distinguish the items inside the image. + +Cover-letter: +tools: mkimage: Add Allwinner TOC1 support + +The SPL port for the Allwinner D1 RISC-V SoC will probably take a while +longer than porting U-Boot proper, as none of the relevant drivers are +set up for DM in SPL. In the meantime, we are using[1][2] a fork[3] of +Allwinner's boot0 loader, which they also call "spl" in their BSP. boot0 +uses this TOC1 image format. + +The vendor tools for generating TOC1 images require a binary config file +generated by their FEX compiler. Instead of trying to support that, I +made up a simple human-readable config file format. I didn't see any +existing platform-agnostic parser for multi-image containers in mkimage. + +I am sending this as RFC because it is only of temporary/limited use. +It only works with one specific fork of boot0 which was modified to +"behave" (the the original vendor version monkey-patches a custom header +inside the U-Boot image during boot). So it will be obsolete once U-Boot +SPL is ported. And it is Yet Another Image Format. On the other hand, it +does work, and it is currently being used. + +[1]: https://linux-sunxi.org/Allwinner_Nezha#U-Boot +[2]: https://fedoraproject.org/wiki/Architectures/RISC-V/Allwinner +[3]: https://github.com/smaeul/sun20i_d1_spl +END +Series-prefix: RFC +Series-to: sunxi +Signed-off-by: Samuel Holland +--- + boot/image.c | 1 + + include/image.h | 1 + + include/sunxi_image.h | 26 ++++ + tools/Makefile | 1 + + tools/sunxi_toc1.c | 318 ++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 347 insertions(+) + create mode 100644 tools/sunxi_toc1.c + +--- a/boot/image.c ++++ b/boot/image.c +@@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] + { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, + { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" }, + { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" }, ++ { IH_TYPE_SUNXI_TOC1, "sunxi_toc1", "Allwinner TOC1 Boot Image" }, + { -1, "", "", }, + }; + +--- a/include/image.h ++++ b/include/image.h +@@ -229,6 +229,7 @@ enum image_type_t { + IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ + IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ + IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */ ++ IH_TYPE_SUNXI_TOC1, /* Allwinner TOC1 Boot Image */ + + IH_TYPE_COUNT, /* Number of image types */ + }; +--- a/include/sunxi_image.h ++++ b/include/sunxi_image.h +@@ -116,4 +116,30 @@ struct __packed toc0_item_info { + #define TOC0_ITEM_INFO_NAME_KEY 0x00010303 + #define TOC0_ITEM_INFO_END "IIE;" + ++struct __packed toc1_main_info { ++ uint8_t name[16]; ++ __le32 magic; ++ __le32 checksum; ++ __le32 serial; ++ __le32 status; ++ __le32 num_items; ++ __le32 length; ++ __le32 major_version; ++ __le32 minor_version; ++ __le32 reserved[3]; ++ uint8_t end[4]; ++}; ++ ++struct __packed toc1_item_info { ++ uint8_t name[64]; ++ __le32 offset; ++ __le32 length; ++ __le32 encryption; ++ __le32 type; ++ __le32 load_addr; ++ __le32 index; ++ __le32 reserved[69]; ++ uint8_t end[4]; ++}; ++ + #endif +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -132,6 +132,7 @@ dumpimage-mkimage-objs := aisimage.o \ + $(ROCKCHIP_OBS) \ + socfpgaimage.o \ + sunxi_egon.o \ ++ sunxi_toc1.o \ + lib/crc16-ccitt.o \ + lib/hash-checksum.o \ + lib/sha1.o \ +--- /dev/null ++++ b/tools/sunxi_toc1.c +@@ -0,0 +1,318 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * (C) Copyright 2018 Arm Ltd. ++ * (C) Copyright 2020-2021 Samuel Holland ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include "imagetool.h" ++#include "mkimage.h" ++ ++#define SECTOR_SIZE 512 ++ ++struct item_desc { ++ const char *name; ++ const char *file; ++ unsigned long addr; ++ long length; ++}; ++ ++static uint32_t toc1_header_length(uint32_t num_items) ++{ ++ return ALIGN(sizeof(struct toc1_main_info) + ++ sizeof(struct toc1_item_info) * num_items, SECTOR_SIZE); ++} ++ ++static int toc1_parse_cfg(const char *file, struct item_desc **desc, ++ uint32_t *main_length, uint32_t *num_items) ++{ ++ struct item_desc *descs = NULL; ++ int ret = EXIT_FAILURE; ++ FILE *cfg, *fp = NULL; ++ uint32_t ndescs = 0; ++ char *line = NULL; ++ size_t len = 0; ++ ++ *desc = NULL; ++ *main_length = 0; ++ *num_items = 0; ++ ++ cfg = fopen(file, "r"); ++ if (!cfg) ++ return ret; ++ ++ while (getline(&line, &len, cfg) > 0) { ++ char *end, *s; ++ ++ if (line[0] == '[') { ++ s = line + 1; ++ end = strchr(s, ']'); ++ if (!end || end[1] != '\n') ++ goto err; ++ end[0] = '\0'; ++ ++ ndescs++; ++ descs = reallocarray(descs, ndescs, sizeof(*descs)); ++ if (!descs) ++ goto err; ++ ++ descs[ndescs - 1].name = strdup(s); ++ } else if (line[0] != '#' && line[0] != '\n') { ++ s = strchr(line, '='); ++ if (!s) ++ goto err; ++ while ((++s)[0] == ' ') ++ ; ++ end = strchr(s, '\n'); ++ if (!end) ++ goto err; ++ end[0] = '\0'; ++ ++ if (!strncmp(line, "file", strlen("file"))) { ++ fp = fopen(s, "rb"); ++ if (!fp) ++ goto err; ++ if (fseek(fp, 0, SEEK_END) < 0) ++ goto err; ++ descs[ndescs - 1].file = strdup(s); ++ descs[ndescs - 1].length = ftell(fp); ++ *main_length += ALIGN(descs[ndescs - 1].length, ++ SECTOR_SIZE); ++ fclose(fp); ++ fp = NULL; ++ } else if (!strncmp(line, "addr", strlen("addr"))) { ++ descs[ndescs - 1].addr = strtoul(s, NULL, 0); ++ } else { ++ goto err; ++ } ++ } ++ } ++ ++ *desc = descs; ++ *main_length += toc1_header_length(ndescs); ++ *num_items = ndescs; ++ ++ ret = EXIT_SUCCESS; ++ ++err: ++ if (fp) ++ fclose(fp); ++ if (ret) ++ free(descs); ++ free(line); ++ fclose(cfg); ++ ++ return ret; ++} ++ ++static int toc1_create(uint8_t *buf, uint32_t len, ++ const struct item_desc *desc, uint32_t num_items) ++{ ++ struct toc1_main_info *main = (void *)buf; ++ struct toc1_item_info *item = (void *)(main + 1); ++ uint32_t item_offset, item_length; ++ uint32_t *buf32 = (void *)buf; ++ int ret = EXIT_FAILURE; ++ uint32_t checksum = 0; ++ FILE *fp = NULL; ++ int i; ++ ++ /* Create the main TOC1 header. */ ++ main->magic = cpu_to_le32(TOC0_MAIN_INFO_MAGIC); ++ main->checksum = cpu_to_le32(BROM_STAMP_VALUE); ++ main->num_items = cpu_to_le32(num_items); ++ memcpy(main->end, TOC0_MAIN_INFO_END, sizeof(main->end)); ++ ++ item_offset = 0; ++ item_length = toc1_header_length(num_items); ++ ++ for (i = 0; i < num_items; ++i, ++item, ++desc) { ++ item_offset = item_offset + item_length; ++ item_length = desc->length; ++ ++ /* Create the item header. */ ++ memcpy(item->name, desc->name, ++ strnlen(desc->name, sizeof(item->name))); ++ item->offset = cpu_to_le32(item_offset); ++ item->length = cpu_to_le32(item_length); ++ item->load_addr = cpu_to_le32(desc->addr); ++ memcpy(item->end, TOC0_ITEM_INFO_END, sizeof(item->end)); ++ ++ /* Read in the data. */ ++ fp = fopen(desc->file, "rb"); ++ if (!fp) ++ goto err; ++ if (!fread(buf + item_offset, item_length, 1, fp)) ++ goto err; ++ fclose(fp); ++ fp = NULL; ++ ++ /* Pad the sectors with 0xff to be flash-friendly. */ ++ item_offset = item_offset + item_length; ++ item_length = ALIGN(item_offset, SECTOR_SIZE) - item_offset; ++ memset(buf + item_offset, 0xff, item_length); ++ } ++ ++ /* Fill in the total padded file length. */ ++ item_offset = item_offset + item_length; ++ main->length = cpu_to_le32(item_offset); ++ ++ /* Verify enough space was provided when creating the image. */ ++ assert(len >= item_offset); ++ ++ /* Calculate the checksum. Yes, it's that simple. */ ++ for (i = 0; i < item_offset / 4; ++i) ++ checksum += le32_to_cpu(buf32[i]); ++ main->checksum = cpu_to_le32(checksum); ++ ++ ret = EXIT_SUCCESS; ++ ++err: ++ if (fp) ++ fclose(fp); ++ ++ return ret; ++} ++ ++static int toc1_verify(const uint8_t *buf, uint32_t len) ++{ ++ const struct toc1_main_info *main = (void *)buf; ++ const struct toc1_item_info *item = (void *)(main + 1); ++ uint32_t checksum = BROM_STAMP_VALUE; ++ uint32_t main_length, num_items; ++ uint32_t *buf32 = (void *)buf; ++ int ret = EXIT_FAILURE; ++ int i; ++ ++ num_items = le32_to_cpu(main->num_items); ++ main_length = le32_to_cpu(main->length); ++ ++ if (len < main_length || main_length < toc1_header_length(num_items)) ++ goto err; ++ ++ /* Verify the main header. */ ++ if (le32_to_cpu(main->magic) != TOC0_MAIN_INFO_MAGIC) ++ goto err; ++ /* Verify the checksum without modifying the buffer. */ ++ for (i = 0; i < main_length / 4; ++i) ++ checksum += le32_to_cpu(buf32[i]); ++ if (checksum != 2 * le32_to_cpu(main->checksum)) ++ goto err; ++ /* The length must be at least 512 byte aligned. */ ++ if (main_length % SECTOR_SIZE) ++ goto err; ++ if (memcmp(main->end, TOC0_MAIN_INFO_END, sizeof(main->end))) ++ goto err; ++ ++ /* Verify each item header. */ ++ for (i = 0; i < num_items; ++i, ++item) ++ if (memcmp(item->end, TOC0_ITEM_INFO_END, sizeof(item->end))) ++ goto err; ++ ++ ret = EXIT_SUCCESS; ++ ++err: ++ return ret; ++} ++ ++static int toc1_check_params(struct image_tool_params *params) ++{ ++ if (!params->dflag) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int toc1_verify_header(unsigned char *buf, int image_size, ++ struct image_tool_params *params) ++{ ++ return toc1_verify(buf, image_size); ++} ++ ++static void toc1_print_header(const void *buf) ++{ ++ const struct toc1_main_info *main = buf; ++ const struct toc1_item_info *item = (void *)(main + 1); ++ uint32_t head_length, main_length, num_items; ++ uint32_t item_offset, item_length, item_addr; ++ int i; ++ ++ num_items = le32_to_cpu(main->num_items); ++ head_length = sizeof(*main) + num_items * sizeof(*item); ++ main_length = le32_to_cpu(main->length); ++ ++ printf("Allwinner TOC1 Image\n" ++ "Size: %d bytes\n" ++ "Contents: %d items\n" ++ " 00000000:%08x Headers\n", ++ main_length, num_items, head_length); ++ ++ for (i = 0; i < num_items; ++i, ++item) { ++ item_offset = le32_to_cpu(item->offset); ++ item_length = le32_to_cpu(item->length); ++ item_addr = le32_to_cpu(item->load_addr); ++ ++ printf(" %08x:%08x => %08x %s\n", ++ item_offset, item_length, item_addr, item->name); ++ } ++} ++ ++static void toc1_set_header(void *buf, struct stat *sbuf, int ifd, ++ struct image_tool_params *params) ++{ ++ /* Image is already written below. */ ++} ++ ++static int toc1_check_image_type(uint8_t type) ++{ ++ return type == IH_TYPE_SUNXI_TOC1 ? 0 : 1; ++} ++ ++static int toc1_vrec_header(struct image_tool_params *params, ++ struct image_type_params *tparams) ++{ ++ uint32_t main_length, num_items; ++ struct item_desc *desc; ++ int ret; ++ ++ /* This "header" contains the entire image. */ ++ params->skipcpy = 1; ++ ++ ret = toc1_parse_cfg(params->datafile, &desc, &main_length, &num_items); ++ if (ret) ++ exit(ret); ++ ++ tparams->header_size = main_length; ++ tparams->hdr = calloc(tparams->header_size, 1); ++ if (!tparams->hdr) ++ exit(ret); ++ ++ ret = toc1_create(tparams->hdr, tparams->header_size, desc, num_items); ++ if (ret) ++ exit(ret); ++ ++ return 0; ++} ++ ++U_BOOT_IMAGE_TYPE( ++ sunxi_toc1, ++ "Allwinner TOC1 Boot Image support", ++ 0, ++ NULL, ++ toc1_check_params, ++ toc1_verify_header, ++ toc1_print_header, ++ toc1_set_header, ++ NULL, ++ toc1_check_image_type, ++ NULL, ++ toc1_vrec_header ++); diff --git a/package/boot/uboot-d1/patches/0034-phy-sun4i-usb-Do-not-drive-VBUS-with-external-VBUS-p.patch b/package/boot/uboot-d1/patches/0034-phy-sun4i-usb-Do-not-drive-VBUS-with-external-VBUS-p.patch new file mode 100644 index 00000000000000..5a2efb16dc196c --- /dev/null +++ b/package/boot/uboot-d1/patches/0034-phy-sun4i-usb-Do-not-drive-VBUS-with-external-VBUS-p.patch @@ -0,0 +1,33 @@ +From 79f7d883d980beea9989d06f9fba4fcc0430176a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 14 Jul 2022 22:14:38 -0500 +Subject: [PATCH 34/90] phy: sun4i-usb: Do not drive VBUS with external VBUS + present + +It is possible to use host-side USB with externally-provided VBUS. For +example, some USB OTG cables have an extra power input which powers +both the board and the USB peripheral. + +To support this setup, skip enabling the VBUS switch/regulator if VBUS +voltage is already present. This behavior matches the Linux PHY driver. + +Signed-off-by: Samuel Holland +--- + drivers/phy/allwinner/phy-sun4i-usb.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/phy/allwinner/phy-sun4i-usb.c ++++ b/drivers/phy/allwinner/phy-sun4i-usb.c +@@ -220,6 +220,12 @@ static int sun4i_usb_phy_power_on(struct + initial_usb_scan_delay = 0; + } + ++ /* For phy0 only turn on Vbus if we don't have an ext. Vbus */ ++ if (phy->id == 0 && sun4i_usb_phy_vbus_detect(phy)) { ++ dev_warn(phy->dev, "External vbus detected, not enabling our own vbus\n"); ++ return 0; ++ } ++ + if (usb_phy->vbus) { + ret = regulator_set_enable(usb_phy->vbus, true); + if (ret && ret != -ENOSYS) diff --git a/package/boot/uboot-d1/patches/0035-mtd-nand-sunxi-Pass-the-device-to-the-init-function.patch b/package/boot/uboot-d1/patches/0035-mtd-nand-sunxi-Pass-the-device-to-the-init-function.patch new file mode 100644 index 00000000000000..4963fbfd71a775 --- /dev/null +++ b/package/boot/uboot-d1/patches/0035-mtd-nand-sunxi-Pass-the-device-to-the-init-function.patch @@ -0,0 +1,163 @@ +From 4bc5cec5361dd6a2ae3bd044c79a4b5227bb9627 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 16 May 2022 00:47:32 -0500 +Subject: [PATCH 35/90] mtd: nand: sunxi: Pass the device to the init function + +This more closely matches the U-Boot driver to the Linux version. + +Series-to: sunxi + +Cover-letter: +mtd: nand: sunxi: Convert to devicetree and the driver model +This series converts the sunxi NAND driver to get its resources (clocks, +resets, pins) from the devicetree, and probe using the driver model. + +In addition to the immediate cleanup, this allows backporting more +patches (bugfixes, newer SoC support) from the Linux driver. +END + +Signed-off-by: Samuel Holland +--- + drivers/mtd/nand/raw/sunxi_nand.c | 39 ++++++++++++++++--------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +--- a/drivers/mtd/nand/raw/sunxi_nand.c ++++ b/drivers/mtd/nand/raw/sunxi_nand.c +@@ -1604,7 +1604,8 @@ static int sunxi_nand_ecc_init(struct mt + return 0; + } + +-static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) ++static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc, ++ ofnode np, int devnum) + { + const struct nand_sdr_timings *timings; + struct sunxi_nand_chip *chip; +@@ -1620,7 +1621,7 @@ static int sunxi_nand_chip_init(ofnode n + + nsels /= sizeof(u32); + if (!nsels || nsels > 8) { +- dev_err(nfc->dev, "invalid reg property size\n"); ++ dev_err(dev, "invalid reg property size\n"); + return -EINVAL; + } + +@@ -1628,7 +1629,7 @@ static int sunxi_nand_chip_init(ofnode n + (nsels * sizeof(struct sunxi_nand_chip_sel)), + GFP_KERNEL); + if (!chip) { +- dev_err(nfc->dev, "could not allocate chip\n"); ++ dev_err(dev, "could not allocate chip\n"); + return -ENOMEM; + } + +@@ -1638,19 +1639,19 @@ static int sunxi_nand_chip_init(ofnode n + for (i = 0; i < nsels; i++) { + ret = ofnode_read_u32_index(np, "reg", i, &tmp); + if (ret) { +- dev_err(nfc->dev, "could not retrieve reg property: %d\n", ++ dev_err(dev, "could not retrieve reg property: %d\n", + ret); + return ret; + } + + if (tmp > NFC_MAX_CS) { +- dev_err(nfc->dev, ++ dev_err(dev, + "invalid reg value: %u (max CS = 7)\n", tmp); + return -EINVAL; + } + + if (test_and_set_bit(tmp, &nfc->assigned_cs)) { +- dev_err(nfc->dev, "CS %d already assigned\n", tmp); ++ dev_err(dev, "CS %d already assigned\n", tmp); + return -EINVAL; + } + +@@ -1661,9 +1662,9 @@ static int sunxi_nand_chip_init(ofnode n + chip->sels[i].rb.type = RB_NATIVE; + chip->sels[i].rb.info.nativeid = tmp; + } else { +- ret = gpio_request_by_name_nodev(np, "rb-gpios", i, +- &chip->sels[i].rb.info.gpio, +- GPIOD_IS_IN); ++ ret = gpio_request_by_name(dev, "rb-gpios", i, ++ &chip->sels[i].rb.info.gpio, ++ GPIOD_IS_IN); + if (ret) + chip->sels[i].rb.type = RB_GPIO; + else +@@ -1674,7 +1675,7 @@ static int sunxi_nand_chip_init(ofnode n + timings = onfi_async_timing_mode_to_sdr_timings(0); + if (IS_ERR(timings)) { + ret = PTR_ERR(timings); +- dev_err(nfc->dev, ++ dev_err(dev, + "could not retrieve timings for ONFI mode 0: %d\n", + ret); + return ret; +@@ -1682,7 +1683,7 @@ static int sunxi_nand_chip_init(ofnode n + + ret = sunxi_nand_chip_set_timings(nfc, chip, timings); + if (ret) { +- dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); ++ dev_err(dev, "could not configure chip timings: %d\n", ret); + return ret; + } + +@@ -1717,25 +1718,25 @@ static int sunxi_nand_chip_init(ofnode n + + ret = sunxi_nand_chip_init_timings(nfc, chip); + if (ret) { +- dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); ++ dev_err(dev, "could not configure chip timings: %d\n", ret); + return ret; + } + + ret = sunxi_nand_ecc_init(mtd, &nand->ecc); + if (ret) { +- dev_err(nfc->dev, "ECC init failed: %d\n", ret); ++ dev_err(dev, "ECC init failed: %d\n", ret); + return ret; + } + + ret = nand_scan_tail(mtd); + if (ret) { +- dev_err(nfc->dev, "nand_scan_tail failed: %d\n", ret); ++ dev_err(dev, "nand_scan_tail failed: %d\n", ret); + return ret; + } + + ret = nand_register(devnum, mtd); + if (ret) { +- dev_err(nfc->dev, "failed to register mtd device: %d\n", ret); ++ dev_err(dev, "failed to register mtd device: %d\n", ret); + return ret; + } + +@@ -1744,13 +1745,13 @@ static int sunxi_nand_chip_init(ofnode n + return 0; + } + +-static int sunxi_nand_chips_init(ofnode node, struct sunxi_nfc *nfc) ++static int sunxi_nand_chips_init(struct udevice *dev, struct sunxi_nfc *nfc) + { + ofnode nand_np; + int ret, i = 0; + +- ofnode_for_each_subnode(nand_np, node) { +- ret = sunxi_nand_chip_init(nand_np, nfc, i++); ++ dev_for_each_subnode(nand_np, dev) { ++ ret = sunxi_nand_chip_init(dev, nfc, nand_np, i++); + if (ret) + return ret; + } +@@ -1802,7 +1803,7 @@ static int sunxi_nand_probe(struct udevi + if (ret) + return ret; + +- ret = sunxi_nand_chips_init(dev_ofnode(dev), nfc); ++ ret = sunxi_nand_chips_init(dev, nfc); + if (ret) { + dev_err(dev, "failed to init nand chips\n"); + return ret; diff --git a/package/boot/uboot-d1/patches/0036-sunxi-Enable-PHY_SUN4I_USB-by-default-for-new-SoCs.patch b/package/boot/uboot-d1/patches/0036-sunxi-Enable-PHY_SUN4I_USB-by-default-for-new-SoCs.patch new file mode 100644 index 00000000000000..0d0bfc0fb41551 --- /dev/null +++ b/package/boot/uboot-d1/patches/0036-sunxi-Enable-PHY_SUN4I_USB-by-default-for-new-SoCs.patch @@ -0,0 +1,120 @@ +From b13140a914199dcdd80331fef6f33d47f008f1b4 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:40:22 -0500 +Subject: [PATCH 36/90] sunxi: Enable PHY_SUN4I_USB by default for new SoCs + +With one exception (sun9i), all sunxi SoCs released to date use variants +of the same USB PHY. Instead of requiring each new SoC to duplicate the +PHY driver selection, enable it by default. + +Series-to: Andre Przywara +Series-to: Jagan Teki + +Signed-off-by: Samuel Holland +--- + arch/arm/mach-sunxi/Kconfig | 11 ----------- + drivers/phy/allwinner/Kconfig | 3 ++- + 2 files changed, 2 insertions(+), 12 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -162,7 +162,6 @@ endif + + config MACH_SUNXI_H3_H5 + bool +- select PHY_SUN4I_USB + select SUNXI_DE2 + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_32BIT +@@ -191,7 +190,6 @@ config MACH_SUNIV + config MACH_SUN4I + bool "sun4i (Allwinner A10)" + select CPU_V7A +- select PHY_SUN4I_USB + select DRAM_SUN4I + select SUNXI_GEN_SUN4I + select SUPPORT_SPL +@@ -202,7 +200,6 @@ config MACH_SUN5I + bool "sun5i (Allwinner A13)" + select CPU_V7A + select DRAM_SUN4I +- select PHY_SUN4I_USB + select SUNXI_GEN_SUN4I + select SUPPORT_SPL + imply SPL_SYS_I2C_LEGACY +@@ -216,7 +213,6 @@ config MACH_SUN6I + select ARCH_SUPPORT_PSCI + select SPL_ARMV7_SET_CORTEX_SMPEN + select DRAM_SUN6I +- select PHY_SUN4I_USB + select SPL_I2C + select SUN6I_PRCM + select SUNXI_GEN_SUN6I +@@ -232,7 +228,6 @@ config MACH_SUN7I + select ARCH_SUPPORT_PSCI + select SPL_ARMV7_SET_CORTEX_SMPEN + select DRAM_SUN4I +- select PHY_SUN4I_USB + select SUNXI_GEN_SUN4I + select SUPPORT_SPL + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT +@@ -246,7 +241,6 @@ config MACH_SUN8I_A23 + select CPU_V7_HAS_VIRT + select ARCH_SUPPORT_PSCI + select DRAM_SUN8I_A23 +- select PHY_SUN4I_USB + select SPL_I2C + select SUNXI_GEN_SUN6I + select SUPPORT_SPL +@@ -260,7 +254,6 @@ config MACH_SUN8I_A33 + select CPU_V7_HAS_VIRT + select ARCH_SUPPORT_PSCI + select DRAM_SUN8I_A33 +- select PHY_SUN4I_USB + select SPL_I2C + select SUNXI_GEN_SUN6I + select SUPPORT_SPL +@@ -271,7 +264,6 @@ config MACH_SUN8I_A83T + bool "sun8i (Allwinner A83T)" + select CPU_V7A + select DRAM_SUN8I_A83T +- select PHY_SUN4I_USB + select SPL_I2C + select SUNXI_GEN_SUN6I + select MMC_SUNXI_HAS_NEW_MODE +@@ -299,7 +291,6 @@ config MACH_SUN8I_R40 + select SUPPORT_SPL + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_32BIT +- select PHY_SUN4I_USB + imply SPL_SYS_I2C_LEGACY + + config MACH_SUN8I_V3S +@@ -327,7 +318,6 @@ config MACH_SUN9I + config MACH_SUN50I + bool "sun50i (Allwinner A64)" + select ARM64 +- select PHY_SUN4I_USB + select SUN6I_PRCM + select SUNXI_DE2 + select SUNXI_GEN_SUN6I +@@ -350,7 +340,6 @@ config MACH_SUN50I_H5 + config MACH_SUN50I_H6 + bool "sun50i (Allwinner H6)" + select ARM64 +- select PHY_SUN4I_USB + select DRAM_SUN50I_H6 + select SUN50I_GEN_H6 + +--- a/drivers/phy/allwinner/Kconfig ++++ b/drivers/phy/allwinner/Kconfig +@@ -3,7 +3,8 @@ + # + config PHY_SUN4I_USB + bool "Allwinner Sun4I USB PHY driver" +- depends on ARCH_SUNXI ++ depends on ARCH_SUNXI && !MACH_SUN9I ++ default y + select DM_REGULATOR + select PHY + help diff --git a/package/boot/uboot-d1/patches/0037-sunxi-psci-Add-support-for-H3-CPU-0-hotplug.patch b/package/boot/uboot-d1/patches/0037-sunxi-psci-Add-support-for-H3-CPU-0-hotplug.patch new file mode 100644 index 00000000000000..040bce409d6d66 --- /dev/null +++ b/package/boot/uboot-d1/patches/0037-sunxi-psci-Add-support-for-H3-CPU-0-hotplug.patch @@ -0,0 +1,183 @@ +From d11c5971f60d482c05f807c24f3ccd37cf7d0f70 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 17:12:57 -0500 +Subject: [PATCH 37/90] sunxi: psci: Add support for H3 CPU 0 hotplug + +Due to a bug in the H3 SoC, where the CPU 0 hotplug flag cannot be +written, resuming CPU 0 requires using the "Super Standby" code path in +the BROM instead of the hotplug path. This path requires jumping to an +eGON image in SRAM. + +Add support to the build system to generate this eGON image and include +it in the FIT, and add code to direct the BROM to its location in SRAM. + +Since the Super Standby code path in the BROM initializes the CPU and +AHB1 clocks to 24 MHz, those registers need to be restored after control +passes back to U-Boot. Furthermore, because the BROM lowers the AHB1 +clock divider to /1 before switching to the lower-frequency parent, +PLL_PERIPH0 must be bypassed to prevent AHB1 from temporarily running at +600 MHz. Otherwise, this locks up the SoC. + +Signed-off-by: Samuel Holland +--- + Makefile | 17 +++++++++++++++++ + arch/arm/cpu/armv7/sunxi/psci.c | 31 +++++++++++++++++++++++++++++++ + arch/arm/dts/sunxi-u-boot.dtsi | 23 ++++++++++++++++++++++- + include/configs/sun8i.h | 4 ++++ + 4 files changed, 74 insertions(+), 1 deletion(-) + +--- a/Makefile ++++ b/Makefile +@@ -1013,6 +1013,23 @@ INPUTS-y += u-boot.img + endif + endif + ++ifeq ($(CONFIG_MACH_SUN8I_H3)$(CONFIG_ARMV7_PSCI),yy) ++INPUTS-$(CONFIG_ARMV7_PSCI) += u-boot-resume.img ++ ++MKIMAGEFLAGS_u-boot-resume.img := -B 0x400 -T sunxi_egon ++ ++u-boot-resume.img: u-boot-resume.bin ++ $(call if_changed,mkimage) ++ ++OBJCOPYFLAGS_u-boot-resume.bin := -O binary ++ ++u-boot-resume.bin: u-boot-resume.o ++ $(call if_changed,objcopy) ++ ++u-boot-resume.S: u-boot ++ @sed -En 's/(0x[[:xdigit:]]+) +psci_cpu_entry/ldr pc, =\1/p' $<.map > $@ ++endif ++ + INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ + $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ + $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) +--- a/arch/arm/cpu/armv7/sunxi/psci.c ++++ b/arch/arm/cpu/armv7/sunxi/psci.c +@@ -10,6 +10,7 @@ + #include + #include + ++#include + #include + #include + #include +@@ -141,6 +142,13 @@ static void __secure sunxi_set_entry_add + (struct sunxi_cpucfg_reg *)SUNXI_CPUCFG_BASE; + + writel((u32)entry, &cpucfg->priv0); ++ ++#ifdef CONFIG_MACH_SUN8I_H3 ++ /* Redirect CPU 0 to the secure monitor via the resume shim. */ ++ writel(0x16aaefe8, &cpucfg->super_standy_flag); ++ writel(0xaa16efe8, &cpucfg->super_standy_flag); ++ writel(SUNXI_RESUME_BASE, &cpucfg->priv1); ++#endif + } + #endif + +@@ -255,9 +263,12 @@ out: + int __secure psci_cpu_on(u32 __always_unused unused, u32 mpidr, u32 pc, + u32 context_id) + { ++ struct sunxi_ccm_reg *ccu = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + struct sunxi_cpucfg_reg *cpucfg = + (struct sunxi_cpucfg_reg *)SUNXI_CPUCFG_BASE; + u32 cpu = (mpidr & 0x3); ++ u32 cpu_clk; ++ u32 bus_clk; + + /* store target PC and context id */ + psci_save(cpu, pc, context_id); +@@ -274,12 +285,32 @@ int __secure psci_cpu_on(u32 __always_un + /* Lock CPU (Disable external debug access) */ + clrbits_le32(&cpucfg->dbg_ctrl1, BIT(cpu)); + ++ if (IS_ENABLED(CONFIG_MACH_SUN8I_H3) && cpu == 0) { ++ /* Save registers that will be clobbered by the BROM. */ ++ cpu_clk = readl(&ccu->cpu_axi_cfg); ++ bus_clk = readl(&ccu->ahb1_apb1_div); ++ ++ /* Bypass PLL_PERIPH0 so AHB1 frequency does not spike. */ ++ setbits_le32(&ccu->pll6_cfg, BIT(25)); ++ } ++ + /* Power up target CPU */ + sunxi_cpu_set_power(cpu, true); + + /* De-assert reset on target CPU */ + writel(BIT(1) | BIT(0), &cpucfg->cpu[cpu].rst); + ++ if (IS_ENABLED(CONFIG_MACH_SUN8I_H3) && cpu == 0) { ++ /* Spin until the BROM has clobbered the clock registers. */ ++ while (readl(&ccu->ahb1_apb1_div) != 0x00001100); ++ ++ /* Restore the registers and turn off PLL_PERIPH0 bypass. */ ++ writel(cpu_clk, &ccu->cpu_axi_cfg); ++ writel(bus_clk, &ccu->ahb1_apb1_div); ++ ++ clrbits_le32(&ccu->pll6_cfg, BIT(25)); ++ } ++ + /* Unlock CPU (Disable external debug access) */ + setbits_le32(&cpucfg->dbg_ctrl1, BIT(cpu)); + +--- a/arch/arm/dts/sunxi-u-boot.dtsi ++++ b/arch/arm/dts/sunxi-u-boot.dtsi +@@ -6,7 +6,11 @@ + #define ARCH "arm" + #endif + +-#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5) ++#if defined(CONFIG_MACH_SUN8I_H3) ++#ifdef CONFIG_ARMV7_PSCI ++#define RESUME_ADDR SUNXI_RESUME_BASE ++#endif ++#elif defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5) + #define BL31_ADDR 0x00044000 + #define SCP_ADDR 0x00050000 + #elif defined(CONFIG_MACH_SUN50I_H6) +@@ -78,6 +82,20 @@ + }; + #endif + ++#ifdef RESUME_ADDR ++ resume { ++ description = "Super Standby resume image"; ++ type = "standalone"; ++ arch = ARCH; ++ compression = "none"; ++ load = ; ++ ++ blob-ext { ++ filename = "u-boot-resume.img"; ++ }; ++ }; ++#endif ++ + #ifdef SCP_ADDR + scp { + description = "SCP firmware"; +@@ -111,6 +129,9 @@ + firmware = "uboot"; + #endif + loadables = ++#ifdef RESUME_ADDR ++ "resume", ++#endif + #ifdef SCP_ADDR + "scp", + #endif +--- a/include/configs/sun8i.h ++++ b/include/configs/sun8i.h +@@ -8,6 +8,10 @@ + #ifndef __CONFIG_H + #define __CONFIG_H + ++#define SUNXI_RESUME_BASE (CONFIG_ARMV7_SECURE_BASE + \ ++ CONFIG_ARMV7_SECURE_MAX_SIZE) ++#define SUNXI_RESUME_SIZE 1024 ++ + #include + + #endif /* __CONFIG_H */ diff --git a/package/boot/uboot-d1/patches/0038-remoteproc-Add-a-driver-for-the-Allwinner-AR100.patch b/package/boot/uboot-d1/patches/0038-remoteproc-Add-a-driver-for-the-Allwinner-AR100.patch new file mode 100644 index 00000000000000..1b0e002ee9f5fd --- /dev/null +++ b/package/boot/uboot-d1/patches/0038-remoteproc-Add-a-driver-for-the-Allwinner-AR100.patch @@ -0,0 +1,155 @@ +From 7585a12ffec6e42c62222d8ee4085413b3a197f7 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 14:58:27 -0500 +Subject: [PATCH 38/90] remoteproc: Add a driver for the Allwinner AR100 + +Signed-off-by: Samuel Holland +--- + drivers/remoteproc/Kconfig | 9 ++ + drivers/remoteproc/Makefile | 1 + + drivers/remoteproc/sun6i_ar100_rproc.c | 111 +++++++++++++++++++++++++ + 3 files changed, 121 insertions(+) + create mode 100644 drivers/remoteproc/sun6i_ar100_rproc.c + +--- a/drivers/remoteproc/Kconfig ++++ b/drivers/remoteproc/Kconfig +@@ -41,6 +41,15 @@ config REMOTEPROC_STM32_COPRO + Say 'y' here to add support for STM32 Cortex-M4 coprocessors via the + remoteproc framework. + ++config REMOTEPROC_SUN6I_AR100 ++ bool "Support for Allwinner AR100 SCP" ++ select REMOTEPROC ++ depends on ARCH_SUNXI ++ help ++ Say 'y' here to support Allwinner's AR100 System Control Processor ++ (SCP), found in various sun6i/sun8i/sun50i family SoCs, through the ++ remoteproc framework. ++ + config REMOTEPROC_TI_K3_ARM64 + bool "Support for TI's K3 based ARM64 remoteproc driver" + select REMOTEPROC +--- a/drivers/remoteproc/Makefile ++++ b/drivers/remoteproc/Makefile +@@ -10,6 +10,7 @@ obj-$(CONFIG_$(SPL_)REMOTEPROC) += rproc + obj-$(CONFIG_K3_SYSTEM_CONTROLLER) += k3_system_controller.o + obj-$(CONFIG_REMOTEPROC_SANDBOX) += sandbox_testproc.o + obj-$(CONFIG_REMOTEPROC_STM32_COPRO) += stm32_copro.o ++obj-$(CONFIG_REMOTEPROC_SUN6I_AR100) += sun6i_ar100_rproc.o + obj-$(CONFIG_REMOTEPROC_TI_K3_ARM64) += ti_k3_arm64_rproc.o + obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o + obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o +--- /dev/null ++++ b/drivers/remoteproc/sun6i_ar100_rproc.c +@@ -0,0 +1,111 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++#include ++#include ++ ++#define SUNXI_SCP_MAGIC 0xb4400012 ++ ++#define OR1K_VEC_FIRST 0x01 ++#define OR1K_VEC_LAST 0x0e ++#define OR1K_VEC_ADDR(n) (0x100 * (n)) ++ ++struct sun6i_ar100_rproc_priv { ++ void *cfg_base; ++ ulong sram_base; ++}; ++ ++static int sun6i_ar100_rproc_load(struct udevice *dev, ulong addr, ulong size) ++{ ++ struct sun6i_ar100_rproc_priv *priv = dev_get_priv(dev); ++ ++ /* Check for a valid SCP firmware. */ ++ if (readl_relaxed(addr) != SUNXI_SCP_MAGIC) ++ return -ENOENT; ++ ++ /* Program exception vectors to the firmware entry point. */ ++ for (u32 i = OR1K_VEC_FIRST; i <= OR1K_VEC_LAST; ++i) { ++ ulong vector = priv->sram_base + OR1K_VEC_ADDR(i); ++ ulong offset = addr - vector; ++ ++ writel_relaxed(offset >> 2, vector); ++ } ++ ++ return 0; ++} ++ ++static int sun6i_ar100_rproc_start(struct udevice *dev) ++{ ++ struct sun6i_ar100_rproc_priv *priv = dev_get_priv(dev); ++ ++ setbits_le32(priv->cfg_base, BIT(0)); ++ ++ return 0; ++} ++ ++static int sun6i_ar100_rproc_stop(struct udevice *dev) ++{ ++ struct sun6i_ar100_rproc_priv *priv = dev_get_priv(dev); ++ ++ clrbits_le32(priv->cfg_base, BIT(0)); ++ ++ return 0; ++} ++ ++static int sun6i_ar100_rproc_reset(struct udevice *dev) ++{ ++ int ret; ++ ++ ret = sun6i_ar100_rproc_stop(dev); ++ if (ret) ++ return ret; ++ ++ return sun6i_ar100_rproc_start(dev); ++} ++ ++static int sun6i_ar100_rproc_is_running(struct udevice *dev) ++{ ++ struct sun6i_ar100_rproc_priv *priv = dev_get_priv(dev); ++ ++ return !(readl_relaxed(priv->cfg_base) & BIT(0)); ++} ++ ++static const struct dm_rproc_ops sun6i_ar100_rproc_ops = { ++ .load = sun6i_ar100_rproc_load, ++ .start = sun6i_ar100_rproc_start, ++ .stop = sun6i_ar100_rproc_stop, ++ .reset = sun6i_ar100_rproc_reset, ++ .is_running = sun6i_ar100_rproc_is_running, ++}; ++ ++static int sun6i_ar100_rproc_probe(struct udevice *dev) ++{ ++ struct sun6i_ar100_rproc_priv *priv = dev_get_priv(dev); ++ struct ofnode_phandle_args sram_handle; ++ int ret; ++ ++ priv->cfg_base = dev_read_addr_ptr(dev); ++ ++ ret = dev_read_phandle_with_args(dev, "sram", NULL, 0, 0, &sram_handle); ++ if (ret) ++ return ret; ++ ++ priv->sram_base = ofnode_get_addr(sram_handle.node); ++ ++ return 0; ++} ++ ++static const struct udevice_id sun6i_ar100_rproc_ids[] = { ++ { .compatible = "allwinner,sun6i-a31-ar100" }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sun6i_ar100_rproc) = { ++ .name = "sun6i_ar100_rproc", ++ .id = UCLASS_REMOTEPROC, ++ .of_match = sun6i_ar100_rproc_ids, ++ .probe = sun6i_ar100_rproc_probe, ++ .priv_auto = sizeof(struct sun6i_ar100_rproc_priv), ++ .ops = &sun6i_ar100_rproc_ops, ++}; diff --git a/package/boot/uboot-d1/patches/0039-arm-dts-sunxi-h3-Add-nodes-for-AR100-remoteproc.patch b/package/boot/uboot-d1/patches/0039-arm-dts-sunxi-h3-Add-nodes-for-AR100-remoteproc.patch new file mode 100644 index 00000000000000..8efaee955c7cc6 --- /dev/null +++ b/package/boot/uboot-d1/patches/0039-arm-dts-sunxi-h3-Add-nodes-for-AR100-remoteproc.patch @@ -0,0 +1,40 @@ +From 2fdd94449c2668b4ff69326ff8d5daabdf2c9f00 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 15:04:16 -0500 +Subject: [PATCH 39/90] arm: dts: sunxi: h3: Add nodes for AR100 remoteproc + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/sun8i-h3.dtsi | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/arch/arm/dts/sun8i-h3.dtsi ++++ b/arch/arm/dts/sun8i-h3.dtsi +@@ -170,6 +170,14 @@ + #size-cells = <1>; + ranges; + ++ sram_a2: sram@40000 { ++ compatible = "mmio-sram"; ++ reg = <0x00040000 0xc000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges = <0 0x00040000 0xc000>; ++ }; ++ + sram_c: sram@1d00000 { + compatible = "mmio-sram"; + reg = <0x01d00000 0x80000>; +@@ -239,6 +247,12 @@ + nvmem-cell-names = "calibration"; + #thermal-sensor-cells = <0>; + }; ++ ++ remoteproc@1f01c00 { ++ compatible = "allwinner,sun6i-a31-ar100"; ++ reg = <0x01f01c00 0x400>; ++ sram = <&sram_a2>; ++ }; + }; + + thermal-zones { diff --git a/package/boot/uboot-d1/patches/0040-sunxi-Enable-support-for-SCP-firmware-on-H3.patch b/package/boot/uboot-d1/patches/0040-sunxi-Enable-support-for-SCP-firmware-on-H3.patch new file mode 100644 index 00000000000000..12773fc6a88e30 --- /dev/null +++ b/package/boot/uboot-d1/patches/0040-sunxi-Enable-support-for-SCP-firmware-on-H3.patch @@ -0,0 +1,63 @@ +From aefe751d6f23c9d526bca447c6c28da97e45e528 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 17 Apr 2021 13:33:54 -0500 +Subject: [PATCH 40/90] sunxi: Enable support for SCP firmware on H3 + +Now that issues with the BROM have been sorted out, we can implement +PSCI system suspend on H3 by delegating to SCP firmware. Let's start by +including the firmware in the FIT image and starting the coprocessor if +valid firmware is loaded. + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/sunxi-u-boot.dtsi | 1 + + board/sunxi/board.c | 8 ++++++++ + include/configs/sun8i.h | 3 +++ + 3 files changed, 12 insertions(+) + +--- a/arch/arm/dts/sunxi-u-boot.dtsi ++++ b/arch/arm/dts/sunxi-u-boot.dtsi +@@ -9,6 +9,7 @@ + #if defined(CONFIG_MACH_SUN8I_H3) + #ifdef CONFIG_ARMV7_PSCI + #define RESUME_ADDR SUNXI_RESUME_BASE ++#define SCP_ADDR SUNXI_SCP_BASE + #endif + #elif defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5) + #define BL31_ADDR 0x00044000 +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -867,6 +868,13 @@ int board_late_init(void) + usb_ether_init(); + #endif + ++#ifdef CONFIG_REMOTEPROC_SUN6I_AR100 ++ if (!rproc_load(0, SUNXI_SCP_BASE, SUNXI_SCP_MAX_SIZE)) { ++ puts("Starting SCP...\n"); ++ rproc_start(0); ++ } ++#endif ++ + return 0; + } + +--- a/include/configs/sun8i.h ++++ b/include/configs/sun8i.h +@@ -12,6 +12,9 @@ + CONFIG_ARMV7_SECURE_MAX_SIZE) + #define SUNXI_RESUME_SIZE 1024 + ++#define SUNXI_SCP_BASE (SUNXI_RESUME_BASE + SUNXI_RESUME_SIZE) ++#define SUNXI_SCP_MAX_SIZE (16 * 1024) ++ + #include + + #endif /* __CONFIG_H */ diff --git a/package/boot/uboot-d1/patches/0041-arm-psci-Add-definitions-for-PSCI-v1.1.patch b/package/boot/uboot-d1/patches/0041-arm-psci-Add-definitions-for-PSCI-v1.1.patch new file mode 100644 index 00000000000000..535c156199d662 --- /dev/null +++ b/package/boot/uboot-d1/patches/0041-arm-psci-Add-definitions-for-PSCI-v1.1.patch @@ -0,0 +1,115 @@ +From f73116f62647c74eb0f06f0d8c29e5993d961d82 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 22:43:26 -0500 +Subject: [PATCH 41/90] arm: psci: Add definitions for PSCI v1.1 + +Add the new option, function IDs, and prototypes for PSCI v1.1 +implementations. In the process, fix some issues with the existing +definitions: + - Fix the incorrectly-named ARM_PSCI_0_2_FN64_SYSTEM_RESET2. + - Replace the deprecated "affinity_level" naming with "power_level". + +Signed-off-by: Samuel Holland +--- + arch/arm/cpu/armv7/Kconfig | 3 +++ + arch/arm/cpu/armv8/fwcall.c | 2 +- + arch/arm/include/asm/psci.h | 9 +++++++-- + arch/arm/include/asm/system.h | 14 +++++++++----- + arch/arm/lib/psci-dt.c | 2 ++ + 5 files changed, 22 insertions(+), 8 deletions(-) + +--- a/arch/arm/cpu/armv7/Kconfig ++++ b/arch/arm/cpu/armv7/Kconfig +@@ -80,6 +80,9 @@ choice + help + Select the supported PSCI version. + ++config ARMV7_PSCI_1_1 ++ bool "PSCI V1.1" ++ + config ARMV7_PSCI_1_0 + bool "PSCI V1.0" + +--- a/arch/arm/cpu/armv8/fwcall.c ++++ b/arch/arm/cpu/armv8/fwcall.c +@@ -103,7 +103,7 @@ void __noreturn psci_system_reset2(u32 r + { + struct pt_regs regs; + +- regs.regs[0] = ARM_PSCI_0_2_FN64_SYSTEM_RESET2; ++ regs.regs[0] = ARM_PSCI_1_1_FN64_SYSTEM_RESET2; + regs.regs[1] = PSCI_RESET2_TYPE_VENDOR | reset_level; + regs.regs[2] = cookie; + if (use_smc_for_psci) +--- a/arch/arm/include/asm/psci.h ++++ b/arch/arm/include/asm/psci.h +@@ -22,8 +22,9 @@ + #include + #endif + +-#define ARM_PSCI_VER_1_0 (0x00010000) + #define ARM_PSCI_VER_0_2 (0x00000002) ++#define ARM_PSCI_VER_1_0 (0x00010000) ++#define ARM_PSCI_VER_1_1 (0x00010001) + + /* PSCI 0.1 interface */ + #define ARM_PSCI_FN_BASE 0x95c1ba5e +@@ -68,7 +69,6 @@ + #define ARM_PSCI_0_2_FN64_AFFINITY_INFO ARM_PSCI_0_2_FN64(4) + #define ARM_PSCI_0_2_FN64_MIGRATE ARM_PSCI_0_2_FN64(5) + #define ARM_PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU ARM_PSCI_0_2_FN64(7) +-#define ARM_PSCI_0_2_FN64_SYSTEM_RESET2 ARM_PSCI_0_2_FN64(18) + + /* PSCI 1.0 interface */ + #define ARM_PSCI_1_0_FN_PSCI_FEATURES ARM_PSCI_0_2_FN(10) +@@ -86,6 +86,11 @@ + #define ARM_PSCI_1_0_FN64_STAT_RESIDENCY ARM_PSCI_0_2_FN64(16) + #define ARM_PSCI_1_0_FN64_STAT_COUNT ARM_PSCI_0_2_FN64(17) + ++/* PSCI 1.1 interface */ ++#define ARM_PSCI_1_1_FN_SYSTEM_RESET2 ARM_PSCI_0_2_FN(18) ++ ++#define ARM_PSCI_1_1_FN64_SYSTEM_RESET2 ARM_PSCI_0_2_FN64(18) ++ + /* 1KB stack per core */ + #define ARM_PSCI_STACK_SHIFT 10 + #define ARM_PSCI_STACK_SIZE (1 << ARM_PSCI_STACK_SHIFT) +--- a/arch/arm/include/asm/system.h ++++ b/arch/arm/include/asm/system.h +@@ -557,16 +557,20 @@ void mmu_page_table_flush(unsigned long + #ifdef CONFIG_ARMV7_PSCI + void psci_arch_cpu_entry(void); + void psci_arch_init(void); ++ + u32 psci_version(void); +-s32 psci_features(u32 function_id, u32 psci_fid); ++s32 psci_cpu_suspend(u32 function_id, u32 power_state, u32 pc, u32 context_id); + s32 psci_cpu_off(void); +-s32 psci_cpu_on(u32 function_id, u32 target_cpu, u32 pc, +- u32 context_id); +-s32 psci_affinity_info(u32 function_id, u32 target_affinity, +- u32 lowest_affinity_level); ++s32 psci_cpu_on(u32 function_id, u32 target_cpu, u32 pc, u32 context_id); ++s32 psci_affinity_info(u32 function_id, u32 target_affinity, u32 power_level); + u32 psci_migrate_info_type(void); + void psci_system_off(void); + void psci_system_reset(void); ++s32 psci_features(u32 function_id, u32 psci_fid); ++s32 psci_cpu_default_suspend(u32 function_id, u32 pc, u32 context_id); ++s32 psci_node_hw_state(u32 function_id, u32 target_cpu, u32 power_level); ++s32 psci_system_suspend(u32 function_id, u32 pc, u32 context_id); ++s32 psci_system_reset2(u32 function_id, u32 reset_type, u32 cookie); + #endif + + #endif /* __ASSEMBLY__ */ +--- a/arch/arm/lib/psci-dt.c ++++ b/arch/arm/lib/psci-dt.c +@@ -66,6 +66,8 @@ int fdt_psci(void *fdt) + init_psci_node: + #if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) + psci_ver = sec_firmware_support_psci_version(); ++#elif defined(CONFIG_ARMV7_PSCI_1_1) ++ psci_ver = ARM_PSCI_VER_1_1; + #elif defined(CONFIG_ARMV7_PSCI_1_0) || defined(CONFIG_ARMV8_PSCI) + psci_ver = ARM_PSCI_VER_1_0; + #elif defined(CONFIG_ARMV7_PSCI_0_2) diff --git a/package/boot/uboot-d1/patches/0042-sunxi-Enable-remoteproc-on-some-H3-boards.patch b/package/boot/uboot-d1/patches/0042-sunxi-Enable-remoteproc-on-some-H3-boards.patch new file mode 100644 index 00000000000000..9aaee317a24503 --- /dev/null +++ b/package/boot/uboot-d1/patches/0042-sunxi-Enable-remoteproc-on-some-H3-boards.patch @@ -0,0 +1,29 @@ +From 6dc0da83dba9570740365d0f1b32f91ae8ba0998 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 11 Oct 2021 03:20:28 -0500 +Subject: [PATCH 42/90] sunxi: Enable remoteproc on some H3 boards + +Signed-off-by: Samuel Holland +--- + configs/orangepi_one_defconfig | 1 + + configs/orangepi_plus2e_defconfig | 1 + + 2 files changed, 2 insertions(+) + +--- a/configs/orangepi_one_defconfig ++++ b/configs/orangepi_one_defconfig +@@ -6,5 +6,6 @@ CONFIG_MACH_SUN8I_H3=y + CONFIG_DRAM_CLK=672 + # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set + CONFIG_SUN8I_EMAC=y ++CONFIG_REMOTEPROC_SUN6I_AR100=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_OHCI_HCD=y +--- a/configs/orangepi_plus2e_defconfig ++++ b/configs/orangepi_plus2e_defconfig +@@ -12,5 +12,6 @@ CONFIG_SPL_SYS_I2C_LEGACY=y + CONFIG_SYS_I2C_MVTWSI=y + CONFIG_SUN8I_EMAC=y + CONFIG_SY8106A_POWER=y ++CONFIG_REMOTEPROC_SUN6I_AR100=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_OHCI_HCD=y diff --git a/package/boot/uboot-d1/patches/0043-sunxi-psci-Delegate-PSCI-to-SCPI.patch b/package/boot/uboot-d1/patches/0043-sunxi-psci-Delegate-PSCI-to-SCPI.patch new file mode 100644 index 00000000000000..6d0c2b49d1b8ae --- /dev/null +++ b/package/boot/uboot-d1/patches/0043-sunxi-psci-Delegate-PSCI-to-SCPI.patch @@ -0,0 +1,497 @@ +From 650fab5c589a883b139b4164527101f9c849f1a5 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 9 Oct 2021 23:01:05 -0500 +Subject: [PATCH 43/90] sunxi: psci: Delegate PSCI to SCPI + +This adds a new PSCI implementation which communicates with SCP firmware +running on the AR100 using the SCPI protocol. This allows it to support +the full set of PSCI v1.1 features, including CPU idle states, system +suspend, and multiple reset methods. + +Signed-off-by: Samuel Holland +--- + arch/arm/cpu/armv7/Kconfig | 1 + + arch/arm/cpu/armv7/sunxi/Makefile | 4 + + arch/arm/cpu/armv7/sunxi/psci-scpi.c | 451 +++++++++++++++++++++++++++ + 3 files changed, 456 insertions(+) + create mode 100644 arch/arm/cpu/armv7/sunxi/psci-scpi.c + +--- a/arch/arm/cpu/armv7/Kconfig ++++ b/arch/arm/cpu/armv7/Kconfig +@@ -75,6 +75,7 @@ config ARMV7_PSCI + choice + prompt "Supported PSCI version" + depends on ARMV7_PSCI ++ default ARMV7_PSCI_1_1 if MACH_SUN8I_H3 + default ARMV7_PSCI_0_1 if ARCH_SUNXI + default ARMV7_PSCI_1_0 + help +--- a/arch/arm/cpu/armv7/sunxi/Makefile ++++ b/arch/arm/cpu/armv7/sunxi/Makefile +@@ -13,8 +13,12 @@ obj-$(CONFIG_MACH_SUN6I) += sram.o + obj-$(CONFIG_MACH_SUN8I) += sram.o + + ifndef CONFIG_SPL_BUILD ++ifdef CONFIG_MACH_SUN8I_H3 ++obj-$(CONFIG_ARMV7_PSCI) += psci-scpi.o ++else + obj-$(CONFIG_ARMV7_PSCI) += psci.o + endif ++endif + + ifdef CONFIG_SPL_BUILD + obj-y += fel_utils.o +--- /dev/null ++++ b/arch/arm/cpu/armv7/sunxi/psci-scpi.c +@@ -0,0 +1,451 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2016 Chen-Yu Tsai ++ * Copyright (C) 2018-2021 Samuel Holland ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define GICD_BASE (SUNXI_GIC400_BASE + GIC_DIST_OFFSET) ++#define GICC_BASE (SUNXI_GIC400_BASE + GIC_CPU_OFFSET_A15) ++ ++#define HW_ON 0 ++#define HW_OFF 1 ++#define HW_STANDBY 2 ++ ++#define MPIDR_AFFLVL0(mpidr) (mpidr & 0xf) ++#define MPIDR_AFFLVL1(mpidr) (mpidr >> 8 & 0xf) ++ ++#define SCPI_SHMEM_BASE 0x0004be00 ++#define SCPI_SHMEM ((struct scpi_shmem *)SCPI_SHMEM_BASE) ++ ++#define SCPI_RX_CHANNEL 1 ++#define SCPI_TX_CHANNEL 0 ++#define SCPI_VIRTUAL_CHANNEL BIT(0) ++ ++#define SCPI_MESSAGE_SIZE 0x100 ++#define SCPI_PAYLOAD_SIZE (SCPI_MESSAGE_SIZE - sizeof(struct scpi_header)) ++ ++#define SUNXI_MSGBOX_BASE 0x01c17000 ++#define REMOTE_IRQ_STAT_REG (SUNXI_MSGBOX_BASE + 0x0050) ++#define LOCAL_IRQ_STAT_REG (SUNXI_MSGBOX_BASE + 0x0070) ++#define MSG_STAT_REG(n) (SUNXI_MSGBOX_BASE + 0x0140 + 0x4 * (n)) ++#define MSG_DATA_REG(n) (SUNXI_MSGBOX_BASE + 0x0180 + 0x4 * (n)) ++ ++#define RX_IRQ(n) BIT(0 + 2 * (n)) ++#define TX_IRQ(n) BIT(1 + 2 * (n)) ++ ++enum { ++ CORE_POWER_LEVEL = 0, ++ CLUSTER_POWER_LEVEL = 1, ++ CSS_POWER_LEVEL = 2, ++}; ++ ++enum { ++ SCPI_CMD_SCP_READY = 0x01, ++ SCPI_CMD_SET_CSS_POWER_STATE = 0x03, ++ SCPI_CMD_GET_CSS_POWER_STATE = 0x04, ++ SCPI_CMD_SET_SYS_POWER_STATE = 0x05, ++}; ++ ++enum { ++ SCPI_E_OK = 0, ++ SCPI_E_PARAM = 1, ++ SCPI_E_ALIGN = 2, ++ SCPI_E_SIZE = 3, ++ SCPI_E_HANDLER = 4, ++ SCPI_E_ACCESS = 5, ++ SCPI_E_RANGE = 6, ++ SCPI_E_TIMEOUT = 7, ++ SCPI_E_NOMEM = 8, ++ SCPI_E_PWRSTATE = 9, ++ SCPI_E_SUPPORT = 10, ++ SCPI_E_DEVICE = 11, ++ SCPI_E_BUSY = 12, ++ SCPI_E_OS = 13, ++ SCPI_E_DATA = 14, ++ SCPI_E_STATE = 15, ++}; ++ ++enum { ++ SCPI_POWER_ON = 0x00, ++ SCPI_POWER_RETENTION = 0x01, ++ SCPI_POWER_OFF = 0x03, ++}; ++ ++enum { ++ SCPI_SYSTEM_SHUTDOWN = 0x00, ++ SCPI_SYSTEM_REBOOT = 0x01, ++ SCPI_SYSTEM_RESET = 0x02, ++}; ++ ++struct scpi_header { ++ u8 command; ++ u8 sender; ++ u16 size; ++ u32 status; ++}; ++ ++struct scpi_message { ++ struct scpi_header header; ++ u8 payload[SCPI_PAYLOAD_SIZE]; ++}; ++ ++struct scpi_shmem { ++ struct scpi_message rx; ++ struct scpi_message tx; ++}; ++ ++static bool __secure_data gic_dist_init; ++ ++static u32 __secure_data lock; ++ ++static inline u32 __secure read_mpidr(void) ++{ ++ u32 val; ++ ++ asm volatile ("mrc p15, 0, %0, c0, c0, 5" : "=r" (val)); ++ ++ return val; ++} ++ ++static void __secure scpi_begin_command(void) ++{ ++ u32 mpidr = read_mpidr(); ++ ++ do { ++ while (readl(&lock)); ++ writel(mpidr, &lock); ++ dsb(); ++ } while (readl(&lock) != mpidr); ++ while (readl(REMOTE_IRQ_STAT_REG) & RX_IRQ(SCPI_TX_CHANNEL)); ++} ++ ++static void __secure scpi_send_command(void) ++{ ++ writel(SCPI_VIRTUAL_CHANNEL, MSG_DATA_REG(SCPI_TX_CHANNEL)); ++} ++ ++static void __secure scpi_wait_response(void) ++{ ++ while (!readl(MSG_STAT_REG(SCPI_RX_CHANNEL))); ++} ++ ++static void __secure scpi_end_command(void) ++{ ++ while (readl(MSG_STAT_REG(SCPI_RX_CHANNEL))) ++ readl(MSG_DATA_REG(SCPI_RX_CHANNEL)); ++ writel(RX_IRQ(SCPI_RX_CHANNEL), LOCAL_IRQ_STAT_REG); ++ writel(0, &lock); ++} ++ ++static void __secure scpi_set_css_power_state(u32 target_cpu, u32 core_state, ++ u32 cluster_state, u32 css_state) ++{ ++ struct scpi_shmem *shmem = SCPI_SHMEM; ++ ++ scpi_begin_command(); ++ ++ shmem->tx.header.command = SCPI_CMD_SET_CSS_POWER_STATE; ++ shmem->tx.header.size = 4; ++ ++ shmem->tx.payload[0] = target_cpu >> 4 | target_cpu; ++ shmem->tx.payload[1] = cluster_state << 4 | core_state; ++ shmem->tx.payload[2] = css_state; ++ shmem->tx.payload[3] = 0; ++ ++ scpi_send_command(); ++ scpi_end_command(); ++} ++ ++static s32 __secure scpi_get_css_power_state(u32 target_cpu, u8 *core_states, ++ u8 *cluster_state) ++{ ++ struct scpi_shmem *shmem = SCPI_SHMEM; ++ u32 cluster = MPIDR_AFFLVL1(target_cpu); ++ u32 offset; ++ s32 ret; ++ ++ scpi_begin_command(); ++ ++ shmem->tx.header.command = SCPI_CMD_GET_CSS_POWER_STATE; ++ shmem->tx.header.size = 0; ++ ++ scpi_send_command(); ++ scpi_wait_response(); ++ ++ for (offset = 0; offset < shmem->rx.header.size; offset += 2) { ++ if ((shmem->rx.payload[offset] & 0xf) == cluster) { ++ *cluster_state = shmem->rx.payload[offset+0] >> 4; ++ *core_states = shmem->rx.payload[offset+1]; ++ ++ break; ++ } ++ } ++ ++ ret = shmem->rx.header.status; ++ ++ scpi_end_command(); ++ ++ return ret; ++} ++ ++static s32 __secure scpi_set_sys_power_state(u32 sys_state) ++{ ++ struct scpi_shmem *shmem = SCPI_SHMEM; ++ s32 ret; ++ ++ scpi_begin_command(); ++ ++ shmem->tx.header.command = SCPI_CMD_SET_SYS_POWER_STATE; ++ shmem->tx.header.size = 1; ++ ++ shmem->tx.payload[0] = sys_state; ++ ++ scpi_send_command(); ++ scpi_wait_response(); ++ ++ ret = shmem->rx.header.status; ++ ++ scpi_end_command(); ++ ++ return ret; ++} ++ ++void psci_enable_smp(void); ++ ++static s32 __secure psci_suspend_common(u32 pc, u32 context_id, u32 core_state, ++ u32 cluster_state, u32 css_state) ++ ++{ ++ u32 target_cpu = read_mpidr(); ++ ++ if (core_state == SCPI_POWER_OFF) ++ psci_save(MPIDR_AFFLVL0(target_cpu), pc, context_id); ++ if (css_state == SCPI_POWER_OFF) ++ gic_dist_init = true; ++ ++ scpi_set_css_power_state(target_cpu, core_state, ++ cluster_state, css_state); ++ ++ psci_cpu_off_common(); ++ ++ wfi(); ++ ++ psci_enable_smp(); ++ ++ return ARM_PSCI_RET_SUCCESS; ++} ++ ++u32 __secure psci_version(void) ++{ ++ return ARM_PSCI_VER_1_1; ++} ++ ++s32 __secure psci_cpu_suspend(u32 __always_unused function_id, ++ u32 power_state, u32 pc, u32 context_id) ++{ ++ return psci_suspend_common(pc, context_id, ++ power_state >> 0 & 0xf, ++ power_state >> 4 & 0xf, ++ power_state >> 8 & 0xf); ++} ++ ++s32 __secure psci_cpu_off(void) ++{ ++ u32 pc = 0, context_id = 0; ++ ++ return psci_suspend_common(pc, context_id, SCPI_POWER_OFF, ++ SCPI_POWER_OFF, SCPI_POWER_ON); ++} ++ ++s32 __secure psci_cpu_on(u32 __always_unused function_id, ++ u32 target_cpu, u32 pc, u32 context_id) ++{ ++ psci_save(MPIDR_AFFLVL0(target_cpu), pc, context_id); ++ ++ scpi_set_css_power_state(target_cpu, SCPI_POWER_ON, ++ SCPI_POWER_ON, SCPI_POWER_ON); ++ ++ return ARM_PSCI_RET_SUCCESS; ++} ++ ++s32 __secure psci_affinity_info(u32 function_id, ++ u32 target_cpu, u32 power_level) ++{ ++ if (power_level != CORE_POWER_LEVEL) ++ return ARM_PSCI_RET_INVAL; ++ ++ /* This happens to have the same HW_ON/HW_OFF encoding. */ ++ return psci_node_hw_state(function_id, target_cpu, power_level); ++} ++ ++void __secure psci_system_off(void) ++{ ++ scpi_set_sys_power_state(SCPI_SYSTEM_SHUTDOWN); ++ ++ /* Wait to be turned off. */ ++ for (;;) wfi(); ++} ++ ++void __secure psci_system_reset(void) ++{ ++ scpi_set_sys_power_state(SCPI_SYSTEM_REBOOT); ++ ++ /* Wait to be turned off. */ ++ for (;;) wfi(); ++} ++ ++s32 __secure psci_features(u32 __always_unused function_id, ++ u32 psci_fid) ++{ ++ switch (psci_fid) { ++ case ARM_PSCI_0_2_FN_PSCI_VERSION: ++ case ARM_PSCI_0_2_FN_CPU_SUSPEND: ++ case ARM_PSCI_0_2_FN_CPU_OFF: ++ case ARM_PSCI_0_2_FN_CPU_ON: ++ case ARM_PSCI_0_2_FN_AFFINITY_INFO: ++ case ARM_PSCI_0_2_FN_SYSTEM_OFF: ++ case ARM_PSCI_0_2_FN_SYSTEM_RESET: ++ case ARM_PSCI_1_0_FN_PSCI_FEATURES: ++ case ARM_PSCI_1_0_FN_CPU_DEFAULT_SUSPEND: ++ case ARM_PSCI_1_0_FN_NODE_HW_STATE: ++ case ARM_PSCI_1_0_FN_SYSTEM_SUSPEND: ++ case ARM_PSCI_1_1_FN_SYSTEM_RESET2: ++ return ARM_PSCI_RET_SUCCESS; ++ default: ++ return ARM_PSCI_RET_NI; ++ } ++} ++ ++s32 __secure psci_cpu_default_suspend(u32 __always_unused function_id, ++ u32 pc, u32 context_id) ++{ ++ return psci_suspend_common(pc, context_id, SCPI_POWER_OFF, ++ SCPI_POWER_OFF, SCPI_POWER_RETENTION); ++} ++ ++s32 __secure psci_node_hw_state(u32 __always_unused function_id, ++ u32 target_cpu, u32 power_level) ++{ ++ u32 core = MPIDR_AFFLVL0(target_cpu); ++ u8 core_states, cluster_state; ++ ++ if (power_level >= CSS_POWER_LEVEL) ++ return HW_ON; ++ if (scpi_get_css_power_state(target_cpu, &core_states, &cluster_state)) ++ return ARM_PSCI_RET_NI; ++ if (power_level == CLUSTER_POWER_LEVEL) { ++ if (cluster_state == SCPI_POWER_ON) ++ return HW_ON; ++ if (cluster_state < SCPI_POWER_OFF) ++ return HW_STANDBY; ++ return HW_OFF; ++ } ++ ++ return (core_states & BIT(core)) ? HW_ON : HW_OFF; ++} ++ ++s32 __secure psci_system_suspend(u32 __always_unused function_id, ++ u32 pc, u32 context_id) ++{ ++ return psci_suspend_common(pc, context_id, SCPI_POWER_OFF, ++ SCPI_POWER_OFF, SCPI_POWER_OFF); ++} ++ ++s32 __secure psci_system_reset2(u32 __always_unused function_id, ++ u32 reset_type, u32 cookie) ++{ ++ s32 ret; ++ ++ if (reset_type) ++ return ARM_PSCI_RET_INVAL; ++ ++ ret = scpi_set_sys_power_state(SCPI_SYSTEM_RESET); ++ if (ret) ++ return ARM_PSCI_RET_INVAL; ++ ++ /* Wait to be turned off. */ ++ for (;;) wfi(); ++} ++ ++/* ++ * R40 is different from other single cluster SoCs. The secondary core ++ * entry address register is in the SRAM controller address range. ++ */ ++#define SUN8I_R40_SRAMC_SOFT_ENTRY_REG0 (0xbc) ++ ++#ifdef CONFIG_MACH_SUN8I_R40 ++/* secondary core entry address is programmed differently on R40 */ ++static void __secure sunxi_set_entry_address(void *entry) ++{ ++ writel((u32)entry, ++ SUNXI_SRAMC_BASE + SUN8I_R40_SRAMC_SOFT_ENTRY_REG0); ++} ++#else ++static void __secure sunxi_set_entry_address(void *entry) ++{ ++ struct sunxi_cpucfg_reg *cpucfg = ++ (struct sunxi_cpucfg_reg *)SUNXI_CPUCFG_BASE; ++ ++ writel((u32)entry, &cpucfg->priv0); ++ ++#ifdef CONFIG_MACH_SUN8I_H3 ++ /* Redirect CPU 0 to the secure monitor via the resume shim. */ ++ writel(0x16aaefe8, &cpucfg->super_standy_flag); ++ writel(0xaa16efe8, &cpucfg->super_standy_flag); ++ writel(SUNXI_RESUME_BASE, &cpucfg->priv1); ++#endif ++} ++#endif ++ ++void __secure psci_arch_init(void) ++{ ++ static bool __secure_data one_time_init = true; ++ ++ if (one_time_init) { ++ /* Set secondary core power-on PC. */ ++ sunxi_set_entry_address(psci_cpu_entry); ++ ++ /* Wait for the SCP firmware to boot. */ ++ scpi_begin_command(); ++ scpi_wait_response(); ++ scpi_end_command(); ++ ++ one_time_init = false; ++ } ++ ++ /* ++ * Copied from arch/arm/cpu/armv7/virt-v7.c ++ * See also gic_resume() in arch/arm/mach-imx/mx7/psci-mx7.c ++ */ ++ if (gic_dist_init) { ++ u32 i, itlinesnr; ++ ++ /* enable the GIC distributor */ ++ writel(readl(GICD_BASE + GICD_CTLR) | 0x03, GICD_BASE + GICD_CTLR); ++ ++ /* TYPER[4:0] contains an encoded number of available interrupts */ ++ itlinesnr = readl(GICD_BASE + GICD_TYPER) & 0x1f; ++ ++ /* set all bits in the GIC group registers to one to allow access ++ * from non-secure state. The first 32 interrupts are private per ++ * CPU and will be set later when enabling the GIC for each core ++ */ ++ for (i = 1; i <= itlinesnr; i++) ++ writel((unsigned)-1, GICD_BASE + GICD_IGROUPRn + 4 * i); ++ ++ gic_dist_init = false; ++ } ++ ++ /* Be cool with non-secure. */ ++ writel(0xff, GICC_BASE + GICC_PMR); ++} diff --git a/package/boot/uboot-d1/patches/0044-sunxi-Enable-SCP-SCPI-on-A33-as-well.patch b/package/boot/uboot-d1/patches/0044-sunxi-Enable-SCP-SCPI-on-A33-as-well.patch new file mode 100644 index 00000000000000..1c677a449f4d1d --- /dev/null +++ b/package/boot/uboot-d1/patches/0044-sunxi-Enable-SCP-SCPI-on-A33-as-well.patch @@ -0,0 +1,95 @@ +From 5a7a91bf9a78a3a73e26d6de975261e62f9fb127 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Wed, 8 Jun 2022 07:55:54 -0500 +Subject: [PATCH 44/90] sunxi: Enable SCP/SCPI on A33 as well + +Signed-off-by: Samuel Holland +--- + arch/arm/cpu/armv7/Kconfig | 2 +- + arch/arm/cpu/armv7/sunxi/Makefile | 2 +- + arch/arm/cpu/armv7/sunxi/psci-scpi.c | 4 ++++ + arch/arm/dts/sun8i-a23-a33.dtsi | 14 ++++++++++++++ + arch/arm/dts/sunxi-u-boot.dtsi | 4 ++-- + 5 files changed, 22 insertions(+), 4 deletions(-) + +--- a/arch/arm/cpu/armv7/Kconfig ++++ b/arch/arm/cpu/armv7/Kconfig +@@ -75,7 +75,7 @@ config ARMV7_PSCI + choice + prompt "Supported PSCI version" + depends on ARMV7_PSCI +- default ARMV7_PSCI_1_1 if MACH_SUN8I_H3 ++ default ARMV7_PSCI_1_1 if MACH_SUN8I_A33 || MACH_SUN8I_H3 + default ARMV7_PSCI_0_1 if ARCH_SUNXI + default ARMV7_PSCI_1_0 + help +--- a/arch/arm/cpu/armv7/sunxi/Makefile ++++ b/arch/arm/cpu/armv7/sunxi/Makefile +@@ -13,7 +13,7 @@ obj-$(CONFIG_MACH_SUN6I) += sram.o + obj-$(CONFIG_MACH_SUN8I) += sram.o + + ifndef CONFIG_SPL_BUILD +-ifdef CONFIG_MACH_SUN8I_H3 ++ifneq ($(CONFIG_MACH_SUN8I_A33)$(CONFIG_MACH_SUN8I_H3),) + obj-$(CONFIG_ARMV7_PSCI) += psci-scpi.o + else + obj-$(CONFIG_ARMV7_PSCI) += psci.o +--- a/arch/arm/cpu/armv7/sunxi/psci-scpi.c ++++ b/arch/arm/cpu/armv7/sunxi/psci-scpi.c +@@ -24,7 +24,11 @@ + #define MPIDR_AFFLVL0(mpidr) (mpidr & 0xf) + #define MPIDR_AFFLVL1(mpidr) (mpidr >> 8 & 0xf) + ++#if defined(CONFIG_MACH_SUN8I_H3) + #define SCPI_SHMEM_BASE 0x0004be00 ++#else ++#define SCPI_SHMEM_BASE 0x00053e00 ++#endif + #define SCPI_SHMEM ((struct scpi_shmem *)SCPI_SHMEM_BASE) + + #define SCPI_RX_CHANNEL 1 +--- a/arch/arm/dts/sun8i-a23-a33.dtsi ++++ b/arch/arm/dts/sun8i-a23-a33.dtsi +@@ -138,6 +138,14 @@ + #size-cells = <1>; + ranges; + ++ sram_a2: sram@40000 { ++ compatible = "mmio-sram"; ++ reg = <0x00040000 0x14000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges = <0 0x00040000 0x14000>; ++ }; ++ + sram_c: sram@1d00000 { + compatible = "mmio-sram"; + reg = <0x01d00000 0x80000>; +@@ -847,5 +855,11 @@ + #address-cells = <1>; + #size-cells = <0>; + }; ++ ++ remoteproc@1f01c00 { ++ compatible = "allwinner,sun6i-a31-ar100"; ++ reg = <0x01f01c00 0x400>; ++ sram = <&sram_a2>; ++ }; + }; + }; +--- a/arch/arm/dts/sunxi-u-boot.dtsi ++++ b/arch/arm/dts/sunxi-u-boot.dtsi +@@ -6,11 +6,11 @@ + #define ARCH "arm" + #endif + ++#if defined(CONFIG_ARMV7_PSCI) && (defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN8I_H3)) + #if defined(CONFIG_MACH_SUN8I_H3) +-#ifdef CONFIG_ARMV7_PSCI + #define RESUME_ADDR SUNXI_RESUME_BASE +-#define SCP_ADDR SUNXI_SCP_BASE + #endif ++#define SCP_ADDR SUNXI_SCP_BASE + #elif defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5) + #define BL31_ADDR 0x00044000 + #define SCP_ADDR 0x00050000 diff --git a/package/boot/uboot-d1/patches/0045-phy-sun4i-usb-Use-DM_GPIO-for-id-vbus_det-GPIOs.patch b/package/boot/uboot-d1/patches/0045-phy-sun4i-usb-Use-DM_GPIO-for-id-vbus_det-GPIOs.patch new file mode 100644 index 00000000000000..8da5fdb3e1ac71 --- /dev/null +++ b/package/boot/uboot-d1/patches/0045-phy-sun4i-usb-Use-DM_GPIO-for-id-vbus_det-GPIOs.patch @@ -0,0 +1,216 @@ +From afa281decfbb174f57341897e0ad50ee9ad3564f Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 17:59:24 +0000 +Subject: [PATCH 45/90] phy: sun4i-usb: Use DM_GPIO for id/vbus_det GPIOs + +Now that the sunxi_gpio driver handles pull-up/down via the driver +model, we can switch to DM_GPIO for these pins with no loss in +functionality. Since the driver now gets its pin configuration from +the device tree, we can remove the Kconfig symbols. + +Signed-off-by: Samuel Holland + +Signed-off-by: Zoltan HERPAI +--- + arch/arm/dts/sun5i-a13-ampe-a76.dts | 6 ++ + .../sun6i-a31s-yones-toptech-bs1078-v2.dts | 1 + + arch/arm/dts/sun8i-a33-sinlinx-sina33.dts | 1 + + arch/arm/mach-sunxi/Kconfig | 14 ---- + drivers/phy/allwinner/phy-sun4i-usb.c | 71 ++++--------------- + 5 files changed, 22 insertions(+), 71 deletions(-) + +--- a/arch/arm/dts/sun5i-a13-ampe-a76.dts ++++ b/arch/arm/dts/sun5i-a13-ampe-a76.dts +@@ -8,6 +8,8 @@ + /dts-v1/; + #include "sun5i-a13.dtsi" + ++#include ++ + / { + model = "Ampe A76"; + compatible = "ampe,a76", "allwinner,sun5i-a13"; +@@ -26,3 +28,7 @@ + pinctrl-0 = <&uart1_pg_pins>; + status = "okay"; + }; ++ ++&usbphy { ++ usb0_id_det-gpios = <&pio 6 2 GPIO_ACTIVE_HIGH>; /* PG2 */ ++}; +--- a/arch/arm/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts ++++ b/arch/arm/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts +@@ -176,6 +176,7 @@ + }; + + &usbphy { ++ usb0_id_det-gpios = <&pio 0 15 GPIO_ACTIVE_HIGH>; /* PA15 */ + usb1_vbus-supply = <®_dldo1>; + usb2_vbus-supply = <®_dc1sw>; + status = "okay"; +--- a/arch/arm/dts/sun8i-a33-sinlinx-sina33.dts ++++ b/arch/arm/dts/sun8i-a33-sinlinx-sina33.dts +@@ -271,5 +271,6 @@ + + &usbphy { + status = "okay"; ++ usb0_id_det-gpios = <&pio 7 8 GPIO_ACTIVE_HIGH>; /* PH8 */ + usb1_vbus-supply = <®_vcc5v0>; /* USB1 VBUS is always on */ + }; +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -655,20 +655,6 @@ config MMC_SUNXI_SLOT_EXTRA + slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable + support for this. + +-config USB0_VBUS_DET +- string "Vbus detect pin for usb0 (otg)" +- default "" +- ---help--- +- Set the Vbus detect pin for usb0 (otg). This takes a string in the +- format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. +- +-config USB0_ID_DET +- string "ID detect pin for usb0 (otg)" +- default "" +- ---help--- +- Set the ID detect pin for usb0 (otg). This takes a string in the +- format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. +- + config I2C0_ENABLE + bool "Enable I2C/TWI controller 0" + default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I_R40 +--- a/drivers/phy/allwinner/phy-sun4i-usb.c ++++ b/drivers/phy/allwinner/phy-sun4i-usb.c +@@ -96,32 +96,8 @@ struct sun4i_usb_phy_cfg { + int missing_phys; + }; + +-struct sun4i_usb_phy_info { +- const char *gpio_vbus_det; +- const char *gpio_id_det; +-} phy_info[] = { +- { +- .gpio_vbus_det = CONFIG_USB0_VBUS_DET, +- .gpio_id_det = CONFIG_USB0_ID_DET, +- }, +- { +- .gpio_vbus_det = NULL, +- .gpio_id_det = NULL, +- }, +- { +- .gpio_vbus_det = NULL, +- .gpio_id_det = NULL, +- }, +- { +- .gpio_vbus_det = NULL, +- .gpio_id_det = NULL, +- }, +-}; +- + struct sun4i_usb_phy_plat { + void __iomem *pmu; +- struct gpio_desc gpio_vbus_det; +- struct gpio_desc gpio_id_det; + struct clk clocks; + struct reset_ctl resets; + struct udevice *vbus; +@@ -132,6 +108,8 @@ struct sun4i_usb_phy_data { + void __iomem *base; + const struct sun4i_usb_phy_cfg *cfg; + struct sun4i_usb_phy_plat *usb_phy; ++ struct gpio_desc id_det_gpio; ++ struct gpio_desc vbus_det_gpio; + struct udevice *vbus_power_supply; + }; + +@@ -393,11 +371,10 @@ static int sun4i_usb_phy_xlate(struct ph + int sun4i_usb_phy_vbus_detect(struct phy *phy) + { + struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev); +- struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id]; + int err = 1, retries = 3; + +- if (dm_gpio_is_valid(&usb_phy->gpio_vbus_det)) { +- err = dm_gpio_get_value(&usb_phy->gpio_vbus_det); ++ if (dm_gpio_is_valid(&data->vbus_det_gpio)) { ++ err = dm_gpio_get_value(&data->vbus_det_gpio); + /* + * Vbus may have been provided by the board and just turned off + * some milliseconds ago on reset. What we're measuring then is +@@ -405,7 +382,7 @@ int sun4i_usb_phy_vbus_detect(struct phy + */ + while (err > 0 && retries--) { + mdelay(100); +- err = dm_gpio_get_value(&usb_phy->gpio_vbus_det); ++ err = dm_gpio_get_value(&data->vbus_det_gpio); + } + } else if (data->vbus_power_supply) { + err = regulator_get_enable(data->vbus_power_supply); +@@ -417,12 +394,11 @@ int sun4i_usb_phy_vbus_detect(struct phy + int sun4i_usb_phy_id_detect(struct phy *phy) + { + struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev); +- struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id]; + +- if (!dm_gpio_is_valid(&usb_phy->gpio_id_det)) +- return -1; ++ if (!dm_gpio_is_valid(&data->id_det_gpio)) ++ return -EOPNOTSUPP; + +- return dm_gpio_get_value(&usb_phy->gpio_id_det); ++ return dm_gpio_get_value(&data->id_det_gpio); + } + + void sun4i_usb_phy_set_squelch_detect(struct phy *phy, bool enabled) +@@ -452,13 +428,18 @@ static int sun4i_usb_phy_probe(struct ud + if (IS_ERR(data->base)) + return PTR_ERR(data->base); + ++ gpio_request_by_name(dev, "usb0_id_det-gpios", 0, &data->id_det_gpio, ++ GPIOD_IS_IN | GPIOD_PULL_UP); ++ ++ gpio_request_by_name(dev, "usb0_vbus_det-gpios", 0, &data->vbus_det_gpio, ++ GPIOD_IS_IN); ++ + device_get_supply_regulator(dev, "usb0_vbus_power-supply", + &data->vbus_power_supply); + + data->usb_phy = plat; + for (i = 0; i < data->cfg->num_phys; i++) { + struct sun4i_usb_phy_plat *phy = &plat[i]; +- struct sun4i_usb_phy_info *info = &phy_info[i]; + char name[20]; + + if (data->cfg->missing_phys & BIT(i)) +@@ -472,30 +453,6 @@ static int sun4i_usb_phy_probe(struct ud + return ret; + } + +- ret = dm_gpio_lookup_name(info->gpio_vbus_det, +- &phy->gpio_vbus_det); +- if (ret == 0) { +- ret = dm_gpio_request(&phy->gpio_vbus_det, +- "usb_vbus_det"); +- if (ret) +- return ret; +- ret = dm_gpio_set_dir_flags(&phy->gpio_vbus_det, +- GPIOD_IS_IN); +- if (ret) +- return ret; +- } +- +- ret = dm_gpio_lookup_name(info->gpio_id_det, &phy->gpio_id_det); +- if (ret == 0) { +- ret = dm_gpio_request(&phy->gpio_id_det, "usb_id_det"); +- if (ret) +- return ret; +- ret = dm_gpio_set_dir_flags(&phy->gpio_id_det, +- GPIOD_IS_IN | GPIOD_PULL_UP); +- if (ret) +- return ret; +- } +- + if (data->cfg->dedicated_clocks) + snprintf(name, sizeof(name), "usb%d_phy", i); + else diff --git a/package/boot/uboot-d1/patches/0046-ARM-dts-sunxi-Add-AXP221-and-AXP809-GPIO-nodes.patch b/package/boot/uboot-d1/patches/0046-ARM-dts-sunxi-Add-AXP221-and-AXP809-GPIO-nodes.patch new file mode 100644 index 00000000000000..97b421eb9d1159 --- /dev/null +++ b/package/boot/uboot-d1/patches/0046-ARM-dts-sunxi-Add-AXP221-and-AXP809-GPIO-nodes.patch @@ -0,0 +1,45 @@ +From 9e34036e651528df9575c2ffb38d78ae1f613481 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 21 Aug 2021 17:11:54 -0500 +Subject: [PATCH 46/90] ARM: dts: sunxi: Add AXP221 and AXP809 GPIO nodes + +These PMICs each have two GPIO pins, and are supported by the axp_gpio +driver. In order to convert the axp_gpio driver to probe using the +device tree, the corresponding device tree nodes must be present. Add +them, following the same binding as the AXP209 and AXP813. + +Signed-off-by: Samuel Holland +--- + arch/arm/dts/axp22x.dtsi | 6 ++++++ + arch/arm/dts/axp809.dtsi | 7 +++++++ + 2 files changed, 13 insertions(+) + +--- a/arch/arm/dts/axp22x.dtsi ++++ b/arch/arm/dts/axp22x.dtsi +@@ -67,6 +67,12 @@ + status = "disabled"; + }; + ++ axp_gpio: gpio { ++ compatible = "x-powers,axp221-gpio"; ++ gpio-controller; ++ #gpio-cells = <2>; ++ }; ++ + regulators { + /* Default work frequency for buck regulators */ + x-powers,dcdc-freq = <3000>; +--- a/arch/arm/dts/axp809.dtsi ++++ b/arch/arm/dts/axp809.dtsi +@@ -50,4 +50,11 @@ + compatible = "x-powers,axp809"; + interrupt-controller; + #interrupt-cells = <1>; ++ ++ axp_gpio: gpio { ++ compatible = "x-powers,axp809-gpio", ++ "x-powers,axp221-gpio"; ++ gpio-controller; ++ #gpio-cells = <2>; ++ }; + }; diff --git a/package/boot/uboot-d1/patches/0047-gpio-axp-Consistently-use-the-axp_gpio-order.patch b/package/boot/uboot-d1/patches/0047-gpio-axp-Consistently-use-the-axp_gpio-order.patch new file mode 100644 index 00000000000000..2deaadd584b3e2 --- /dev/null +++ b/package/boot/uboot-d1/patches/0047-gpio-axp-Consistently-use-the-axp_gpio-order.patch @@ -0,0 +1,58 @@ +From 7e85c2d6516e47b537b27132d1946d1eab3b8923 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 27 Aug 2021 17:39:36 -0500 +Subject: [PATCH 47/90] gpio: axp: Consistently use the "axp_gpio" order + +This is less confusing than half of the driver using "axp_gpio" and the +other half using "gpio_axp". + +Signed-off-by: Samuel Holland +--- + drivers/gpio/axp_gpio.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -89,14 +89,14 @@ static int axp_gpio_set_value(struct ude + AXP_GPIO_CTRL_OUTPUT_LOW); + } + +-static const struct dm_gpio_ops gpio_axp_ops = { ++static const struct dm_gpio_ops axp_gpio_ops = { + .direction_input = axp_gpio_direction_input, + .direction_output = axp_gpio_direction_output, + .get_value = axp_gpio_get_value, + .set_value = axp_gpio_set_value, + }; + +-static int gpio_axp_probe(struct udevice *dev) ++static int axp_gpio_probe(struct udevice *dev) + { + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + +@@ -107,11 +107,11 @@ static int gpio_axp_probe(struct udevice + return 0; + } + +-U_BOOT_DRIVER(gpio_axp) = { +- .name = "gpio_axp", +- .id = UCLASS_GPIO, +- .ops = &gpio_axp_ops, +- .probe = gpio_axp_probe, ++U_BOOT_DRIVER(axp_gpio) = { ++ .name = "axp_gpio", ++ .id = UCLASS_GPIO, ++ .probe = axp_gpio_probe, ++ .ops = &axp_gpio_ops, + }; + + int axp_gpio_init(void) +@@ -124,7 +124,7 @@ int axp_gpio_init(void) + return ret; + + /* There is no devicetree support for the axp yet, so bind directly */ +- ret = device_bind_driver(dm_root(), "gpio_axp", "AXP-gpio", &dev); ++ ret = device_bind_driver(dm_root(), "axp_gpio", "AXP-gpio", &dev); + if (ret) + return ret; + diff --git a/package/boot/uboot-d1/patches/0048-gpio-axp-Bind-via-device-tree.patch b/package/boot/uboot-d1/patches/0048-gpio-axp-Bind-via-device-tree.patch new file mode 100644 index 00000000000000..dbc61875d2cb77 --- /dev/null +++ b/package/boot/uboot-d1/patches/0048-gpio-axp-Bind-via-device-tree.patch @@ -0,0 +1,139 @@ +From a39b1bd1ad0babb355a5cb6f6a3bd8e378433b54 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 27 Aug 2021 21:43:19 -0500 +Subject: [PATCH 48/90] gpio: axp: Bind via device tree + +Now that the PMIC has a DM driver and binds device tree subnodes, the +GPIO device can be bound that way, instead of from inside board code. + +Since the driver still uses the single set of register definitions from +axpXXX.h (as selected by AXPxxx_POWER), it does not differentiate among +the supported compatibles. + +Signed-off-by: Samuel Holland +--- + arch/arm/include/asm/arch-sunxi/gpio.h | 6 ----- + arch/arm/mach-sunxi/Kconfig | 6 ----- + board/sunxi/board.c | 4 --- + drivers/gpio/Kconfig | 8 ++++++ + drivers/gpio/axp_gpio.c | 34 +++++++++++--------------- + 5 files changed, 22 insertions(+), 36 deletions(-) + +--- a/arch/arm/include/asm/arch-sunxi/gpio.h ++++ b/arch/arm/include/asm/arch-sunxi/gpio.h +@@ -219,10 +219,4 @@ void sunxi_gpio_set_pull(u32 pin, u32 va + void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val); + int sunxi_name_to_gpio(const char *name); + +-#if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO +-int axp_gpio_init(void); +-#else +-static inline int axp_gpio_init(void) { return 0; } +-#endif +- + #endif /* _SUNXI_GPIO_H */ +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -682,12 +682,6 @@ config R_I2C_ENABLE + Set this to y to enable the I2C controller which is part of the PRCM. + endif + +-config AXP_GPIO +- bool "Enable support for gpio-s on axp PMICs" +- depends on AXP_PMIC_BUS +- ---help--- +- Say Y here to enable support for the gpio pins of the axp PMIC ICs. +- + config AXP_DISABLE_BOOT_ON_POWERON + bool "Disable device boot on power plug-in" + depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -221,10 +221,6 @@ int board_init(void) + } + #endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */ + +- ret = axp_gpio_init(); +- if (ret) +- return ret; +- + /* strcmp() would look better, but doesn't get optimised away. */ + if (CONFIG_SATAPWR[0]) { + satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR); +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -104,6 +104,14 @@ config ALTERA_PIO + Select this to enable PIO for Altera devices. Please find + details on the "Embedded Peripherals IP User Guide" of Altera. + ++config AXP_GPIO ++ bool "X-Powers AXP PMICs GPIO driver" ++ depends on DM_GPIO && PMIC_AXP ++ depends on AXP_PMIC_BUS ++ help ++ This driver supports the GPIO pins on ++ X-Powers AXP152, AXP2xx, and AXP8xx PMICs. ++ + config BCM2835_GPIO + bool "BCM2835 GPIO driver" + depends on DM_GPIO +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -10,9 +10,6 @@ + #include + #include + #include +-#include +-#include +-#include + #include + + #define AXP_GPIO_PREFIX "AXP0-" +@@ -99,6 +96,11 @@ static const struct dm_gpio_ops axp_gpio + static int axp_gpio_probe(struct udevice *dev) + { + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); ++ int ret; ++ ++ ret = pmic_bus_init(); ++ if (ret) ++ return ret; + + /* Tell the uclass how many GPIOs we have */ + uc_priv->bank_name = AXP_GPIO_PREFIX; +@@ -107,26 +109,18 @@ static int axp_gpio_probe(struct udevice + return 0; + } + ++static const struct udevice_id axp_gpio_ids[] = { ++ { .compatible = "x-powers,axp152-gpio" }, ++ { .compatible = "x-powers,axp209-gpio" }, ++ { .compatible = "x-powers,axp221-gpio" }, ++ { .compatible = "x-powers,axp813-gpio" }, ++ { } ++}; ++ + U_BOOT_DRIVER(axp_gpio) = { + .name = "axp_gpio", + .id = UCLASS_GPIO, ++ .of_match = axp_gpio_ids, + .probe = axp_gpio_probe, + .ops = &axp_gpio_ops, + }; +- +-int axp_gpio_init(void) +-{ +- struct udevice *dev; +- int ret; +- +- ret = pmic_bus_init(); +- if (ret) +- return ret; +- +- /* There is no devicetree support for the axp yet, so bind directly */ +- ret = device_bind_driver(dm_root(), "axp_gpio", "AXP-gpio", &dev); +- if (ret) +- return ret; +- +- return 0; +-} diff --git a/package/boot/uboot-d1/patches/0049-gpio-axp-Use-DM_PMIC-functions-for-register-access.patch b/package/boot/uboot-d1/patches/0049-gpio-axp-Use-DM_PMIC-functions-for-register-access.patch new file mode 100644 index 00000000000000..c95e81ac4630ca --- /dev/null +++ b/package/boot/uboot-d1/patches/0049-gpio-axp-Use-DM_PMIC-functions-for-register-access.patch @@ -0,0 +1,99 @@ +From 532b81ac600b6a70a1421f86503cb6d8543edf1b Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Tue, 17 Aug 2021 20:01:55 -0500 +Subject: [PATCH 49/90] gpio: axp: Use DM_PMIC functions for register access + +Now that the PMIC driver implements the DM_PMIC uclass, those functions +can be used instead of the platform-specific "pmic_bus" functions. + +Since the driver still uses the single set of register definitions from +axpXXX.h (as selected by AXPxxx_POWER), it still depends on one of those +choices, and therefore also AXP_PMIC_BUS. + +Signed-off-by: Samuel Holland +--- + drivers/gpio/axp_gpio.c | 27 ++++++++++++--------------- + 1 file changed, 12 insertions(+), 15 deletions(-) + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -6,11 +6,11 @@ + */ + + #include +-#include + #include + #include + #include + #include ++#include + + #define AXP_GPIO_PREFIX "AXP0-" + #define AXP_GPIO_COUNT 4 +@@ -40,7 +40,7 @@ static int axp_gpio_direction_input(stru + if (reg == 0) + return -EINVAL; + +- return pmic_bus_write(reg, AXP_GPIO_CTRL_INPUT); ++ return pmic_reg_write(dev->parent, reg, AXP_GPIO_CTRL_INPUT); + } + + static int axp_gpio_direction_output(struct udevice *dev, unsigned pin, +@@ -52,26 +52,27 @@ static int axp_gpio_direction_output(str + if (reg == 0) + return -EINVAL; + +- return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); ++ return pmic_reg_write(dev->parent, reg, ++ val ? AXP_GPIO_CTRL_OUTPUT_HIGH : ++ AXP_GPIO_CTRL_OUTPUT_LOW); + } + + static int axp_gpio_get_value(struct udevice *dev, unsigned pin) + { +- u8 reg, val, mask; ++ u8 reg, mask; + int ret; + + reg = axp_get_gpio_ctrl_reg(pin); + if (reg == 0) + return -EINVAL; + +- ret = pmic_bus_read(AXP_GPIO_STATE, &val); +- if (ret) ++ ret = pmic_reg_read(dev->parent, AXP_GPIO_STATE); ++ if (ret < 0) + return ret; + + mask = 1 << (pin + AXP_GPIO_STATE_OFFSET); + +- return (val & mask) ? 1 : 0; ++ return (ret & mask) ? 1 : 0; + } + + static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val) +@@ -82,8 +83,9 @@ static int axp_gpio_set_value(struct ude + if (reg == 0) + return -EINVAL; + +- return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); ++ return pmic_reg_write(dev->parent, reg, ++ val ? AXP_GPIO_CTRL_OUTPUT_HIGH : ++ AXP_GPIO_CTRL_OUTPUT_LOW); + } + + static const struct dm_gpio_ops axp_gpio_ops = { +@@ -96,11 +98,6 @@ static const struct dm_gpio_ops axp_gpio + static int axp_gpio_probe(struct udevice *dev) + { + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); +- int ret; +- +- ret = pmic_bus_init(); +- if (ret) +- return ret; + + /* Tell the uclass how many GPIOs we have */ + uc_priv->bank_name = AXP_GPIO_PREFIX; diff --git a/package/boot/uboot-d1/patches/0050-gpio-axp-Select-variant-from-compatible-at-runtime.patch b/package/boot/uboot-d1/patches/0050-gpio-axp-Select-variant-from-compatible-at-runtime.patch new file mode 100644 index 00000000000000..c4dfcc94a67fb1 --- /dev/null +++ b/package/boot/uboot-d1/patches/0050-gpio-axp-Select-variant-from-compatible-at-runtime.patch @@ -0,0 +1,375 @@ +From 697eb56ed8c9b3814ddbd87ae0c6e749ccafc9e3 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 28 Aug 2021 00:27:19 -0500 +Subject: [PATCH 50/90] gpio: axp: Select variant from compatible at runtime + +There are three major variants of the AXP PMIC GPIO functionality (plus +PMICs with no GPIOs at all). Except for GPIO3 on the AXP209, which uses +a different register layout, it is straightforward to support all three +variants with a single driver. Do this, and in the process remove the +GPIO-related definitions from the PMIC-specific headers, and therefore +the dependency on AXP_PMIC_BUS. + +Signed-off-by: Samuel Holland +--- + drivers/gpio/Kconfig | 1 - + drivers/gpio/axp_gpio.c | 137 +++++++++++++++++++++------------------- + drivers/power/axp209.c | 6 +- + drivers/power/axp221.c | 4 +- + include/axp152.h | 10 --- + include/axp209.h | 16 ++--- + include/axp221.h | 13 ++-- + include/axp809.h | 8 --- + include/axp818.h | 8 --- + 9 files changed, 89 insertions(+), 114 deletions(-) + +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -107,7 +107,6 @@ config ALTERA_PIO + config AXP_GPIO + bool "X-Powers AXP PMICs GPIO driver" + depends on DM_GPIO && PMIC_AXP +- depends on AXP_PMIC_BUS + help + This driver supports the GPIO pins on + X-Powers AXP152, AXP2xx, and AXP8xx PMICs. +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -7,110 +7,117 @@ + + #include + #include +-#include + #include ++#include + #include + #include + + #define AXP_GPIO_PREFIX "AXP0-" + #define AXP_GPIO_COUNT 4 + +-static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val); +- +-static u8 axp_get_gpio_ctrl_reg(unsigned pin) +-{ +- switch (pin) { +- case 0: return AXP_GPIO0_CTRL; +- case 1: return AXP_GPIO1_CTRL; +-#ifdef AXP_GPIO2_CTRL +- case 2: return AXP_GPIO2_CTRL; +-#endif +-#ifdef AXP_GPIO3_CTRL +- case 3: return AXP_GPIO3_CTRL; +-#endif +- } +- return 0; +-} +- +-static int axp_gpio_direction_input(struct udevice *dev, unsigned pin) +-{ +- u8 reg; +- +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; +- +- return pmic_reg_write(dev->parent, reg, AXP_GPIO_CTRL_INPUT); +-} +- +-static int axp_gpio_direction_output(struct udevice *dev, unsigned pin, +- int val) +-{ +- u8 reg; +- +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; +- +- return pmic_reg_write(dev->parent, reg, +- val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); +-} ++#define AXP_GPIO_CTRL_MASK 0x7 ++#define AXP_GPIO_CTRL_OUTPUT_LOW 0 ++#define AXP_GPIO_CTRL_OUTPUT_HIGH 1 ++ ++struct axp_gpio_desc { ++ const u8 *pins; ++ u8 npins; ++ u8 status_reg; ++ u8 status_offset; ++ u8 input_mux; ++}; + + static int axp_gpio_get_value(struct udevice *dev, unsigned pin) + { +- u8 reg, mask; ++ const struct axp_gpio_desc *desc = dev_get_priv(dev); + int ret; + +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) +- return -EINVAL; +- +- ret = pmic_reg_read(dev->parent, AXP_GPIO_STATE); ++ ret = pmic_reg_read(dev->parent, desc->status_reg); + if (ret < 0) + return ret; + +- mask = 1 << (pin + AXP_GPIO_STATE_OFFSET); +- +- return (ret & mask) ? 1 : 0; ++ return !!(ret & BIT(desc->status_offset + pin)); + } + +-static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val) ++static int axp_gpio_set_flags(struct udevice *dev, unsigned pin, ulong flags) + { +- u8 reg; ++ const struct axp_gpio_desc *desc = dev_get_priv(dev); ++ u8 mux; + +- reg = axp_get_gpio_ctrl_reg(pin); +- if (reg == 0) ++ if (flags & (GPIOD_MASK_DSTYPE | GPIOD_MASK_PULL)) + return -EINVAL; + +- return pmic_reg_write(dev->parent, reg, +- val ? AXP_GPIO_CTRL_OUTPUT_HIGH : +- AXP_GPIO_CTRL_OUTPUT_LOW); ++ if (flags & GPIOD_IS_IN) ++ mux = desc->input_mux; ++ else if (flags & GPIOD_IS_OUT_ACTIVE) ++ mux = AXP_GPIO_CTRL_OUTPUT_HIGH; ++ else ++ mux = AXP_GPIO_CTRL_OUTPUT_LOW; ++ ++ return pmic_clrsetbits(dev->parent, desc->pins[pin], ++ AXP_GPIO_CTRL_MASK, mux); + } + + static const struct dm_gpio_ops axp_gpio_ops = { +- .direction_input = axp_gpio_direction_input, +- .direction_output = axp_gpio_direction_output, + .get_value = axp_gpio_get_value, +- .set_value = axp_gpio_set_value, ++ .xlate = gpio_xlate_offs_flags, ++ .set_flags = axp_gpio_set_flags, + }; + + static int axp_gpio_probe(struct udevice *dev) + { ++ struct axp_gpio_desc *desc = (void *)dev_get_driver_data(dev); + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + ++ dev_set_priv(dev, desc); ++ + /* Tell the uclass how many GPIOs we have */ + uc_priv->bank_name = AXP_GPIO_PREFIX; +- uc_priv->gpio_count = AXP_GPIO_COUNT; ++ uc_priv->gpio_count = desc->npins; + + return 0; + } + ++static const u8 axp152_gpio_pins[] = { ++ 0x90, 0x91, 0x92, 0x93, ++}; ++ ++static const struct axp_gpio_desc axp152_gpio_desc = { ++ .pins = axp152_gpio_pins, ++ .npins = ARRAY_SIZE(axp152_gpio_pins), ++ .status_reg = 0x97, ++ .status_offset = 4, ++ .input_mux = 3, ++}; ++ ++static const u8 axp209_gpio_pins[] = { ++ 0x90, 0x92, 0x93, ++}; ++ ++static const struct axp_gpio_desc axp209_gpio_desc = { ++ .pins = axp209_gpio_pins, ++ .npins = ARRAY_SIZE(axp209_gpio_pins), ++ .status_reg = 0x94, ++ .status_offset = 4, ++ .input_mux = 2, ++}; ++ ++static const u8 axp221_gpio_pins[] = { ++ 0x90, 0x92, ++}; ++ ++static const struct axp_gpio_desc axp221_gpio_desc = { ++ .pins = axp221_gpio_pins, ++ .npins = ARRAY_SIZE(axp221_gpio_pins), ++ .status_reg = 0x94, ++ .input_mux = 2, ++}; ++ + static const struct udevice_id axp_gpio_ids[] = { +- { .compatible = "x-powers,axp152-gpio" }, +- { .compatible = "x-powers,axp209-gpio" }, +- { .compatible = "x-powers,axp221-gpio" }, +- { .compatible = "x-powers,axp813-gpio" }, ++ { .compatible = "x-powers,axp152-gpio", .data = (ulong)&axp152_gpio_desc }, ++ { .compatible = "x-powers,axp209-gpio", .data = (ulong)&axp209_gpio_desc }, ++ { .compatible = "x-powers,axp221-gpio", .data = (ulong)&axp221_gpio_desc }, ++ { .compatible = "x-powers,axp813-gpio", .data = (ulong)&axp221_gpio_desc }, + { } + }; + +--- a/drivers/power/axp209.c ++++ b/drivers/power/axp209.c +@@ -215,15 +215,15 @@ int axp_init(void) + * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting + * from android these are sometimes on. + */ +- rc = pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT); ++ rc = pmic_bus_write(AXP209_GPIO0_CTRL, AXP209_GPIO_CTRL_INPUT); + if (rc) + return rc; + +- rc = pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT); ++ rc = pmic_bus_write(AXP209_GPIO1_CTRL, AXP209_GPIO_CTRL_INPUT); + if (rc) + return rc; + +- rc = pmic_bus_write(AXP_GPIO2_CTRL, AXP_GPIO_CTRL_INPUT); ++ rc = pmic_bus_write(AXP209_GPIO2_CTRL, AXP209_GPIO_CTRL_INPUT); + if (rc) + return rc; + +--- a/drivers/power/axp221.c ++++ b/drivers/power/axp221.c +@@ -226,11 +226,11 @@ int axp_init(void) + * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting + * from android these are sometimes on. + */ +- ret = pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT); ++ ret = pmic_bus_write(AXP221_GPIO0_CTRL, AXP221_GPIO_CTRL_INPUT); + if (ret) + return ret; + +- ret = pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT); ++ ret = pmic_bus_write(AXP221_GPIO1_CTRL, AXP221_GPIO_CTRL_INPUT); + if (ret) + return ret; + +--- a/include/axp152.h ++++ b/include/axp152.h +@@ -14,17 +14,7 @@ enum axp152_reg { + + #define AXP152_POWEROFF (1 << 7) + +-/* For axp_gpio.c */ + #ifdef CONFIG_AXP152_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_GPIO0_CTRL 0x90 +-#define AXP_GPIO1_CTRL 0x91 +-#define AXP_GPIO2_CTRL 0x92 +-#define AXP_GPIO3_CTRL 0x93 +-#define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +-#define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */ +-#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */ +-#define AXP_GPIO_STATE 0x97 +-#define AXP_GPIO_STATE_OFFSET 0 + #endif +--- a/include/axp209.h ++++ b/include/axp209.h +@@ -21,6 +21,9 @@ enum axp209_reg { + AXP209_IRQ_ENABLE5 = 0x44, + AXP209_IRQ_STATUS5 = 0x4c, + AXP209_SHUTDOWN = 0x32, ++ AXP209_GPIO0_CTRL = 0x90, ++ AXP209_GPIO1_CTRL = 0x92, ++ AXP209_GPIO2_CTRL = 0x93, + }; + + #define AXP209_POWER_STATUS_ON_BY_DC BIT(0) +@@ -73,16 +76,11 @@ enum axp209_reg { + + #define AXP209_POWEROFF BIT(7) + +-/* For axp_gpio.c */ ++#define AXP209_GPIO_CTRL_OUTPUT_LOW 0x00 ++#define AXP209_GPIO_CTRL_OUTPUT_HIGH 0x01 ++#define AXP209_GPIO_CTRL_INPUT 0x02 ++ + #ifdef CONFIG_AXP209_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_GPIO0_CTRL 0x90 +-#define AXP_GPIO1_CTRL 0x92 +-#define AXP_GPIO2_CTRL 0x93 +-#define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +-#define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */ +-#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */ +-#define AXP_GPIO_STATE 0x94 +-#define AXP_GPIO_STATE_OFFSET 4 + #endif +--- a/include/axp221.h ++++ b/include/axp221.h +@@ -44,20 +44,17 @@ + #define AXP221_ALDO3_CTRL 0x2a + #define AXP221_SHUTDOWN 0x32 + #define AXP221_SHUTDOWN_POWEROFF (1 << 7) ++#define AXP221_GPIO0_CTRL 0x90 ++#define AXP221_GPIO1_CTRL 0x92 ++#define AXP221_GPIO_CTRL_OUTPUT_LOW 0x00 ++#define AXP221_GPIO_CTRL_OUTPUT_HIGH 0x01 ++#define AXP221_GPIO_CTRL_INPUT 0x02 + #define AXP221_PAGE 0xff + + /* Page 1 addresses */ + #define AXP221_SID 0x20 + +-/* For axp_gpio.c */ + #ifdef CONFIG_AXP221_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_GPIO0_CTRL 0x90 +-#define AXP_GPIO1_CTRL 0x92 +-#define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +-#define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */ +-#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */ +-#define AXP_GPIO_STATE 0x94 +-#define AXP_GPIO_STATE_OFFSET 0 + #endif +--- a/include/axp809.h ++++ b/include/axp809.h +@@ -43,15 +43,7 @@ + #define AXP809_SHUTDOWN 0x32 + #define AXP809_SHUTDOWN_POWEROFF (1 << 7) + +-/* For axp_gpio.c */ + #ifdef CONFIG_AXP809_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_GPIO0_CTRL 0x90 +-#define AXP_GPIO1_CTRL 0x92 +-#define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +-#define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */ +-#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */ +-#define AXP_GPIO_STATE 0x94 +-#define AXP_GPIO_STATE_OFFSET 0 + #endif +--- a/include/axp818.h ++++ b/include/axp818.h +@@ -57,15 +57,7 @@ + #define AXP818_SHUTDOWN 0x32 + #define AXP818_SHUTDOWN_POWEROFF (1 << 7) + +-/* For axp_gpio.c */ + #ifdef CONFIG_AXP818_POWER + #define AXP_POWER_STATUS 0x00 + #define AXP_POWER_STATUS_ALDO_IN BIT(0) +-#define AXP_GPIO0_CTRL 0x90 +-#define AXP_GPIO1_CTRL 0x92 +-#define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */ +-#define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */ +-#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */ +-#define AXP_GPIO_STATE 0x94 +-#define AXP_GPIO_STATE_OFFSET 0 + #endif diff --git a/package/boot/uboot-d1/patches/0051-gpio-axp-Add-support-for-getting-the-pin-function.patch b/package/boot/uboot-d1/patches/0051-gpio-axp-Add-support-for-getting-the-pin-function.patch new file mode 100644 index 00000000000000..b8ede75c2a51b9 --- /dev/null +++ b/package/boot/uboot-d1/patches/0051-gpio-axp-Add-support-for-getting-the-pin-function.patch @@ -0,0 +1,49 @@ +From 37e19d9b8a23c88413dd845dbb3dd58dd3636a6d Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 28 Aug 2021 00:36:33 -0500 +Subject: [PATCH 51/90] gpio: axp: Add support for getting the pin function + +Implement the .get_function operation, so the gpio command can report +the current function. Since the GPIOF_FUNC (versus GPIOF_UNUSED) mux +values vary among the PMICs, report all non-GPIO mux values as UNKNOWN. + +Signed-off-by: Samuel Holland +--- + drivers/gpio/axp_gpio.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -39,6 +39,24 @@ static int axp_gpio_get_value(struct ude + return !!(ret & BIT(desc->status_offset + pin)); + } + ++static int axp_gpio_get_function(struct udevice *dev, unsigned pin) ++{ ++ const struct axp_gpio_desc *desc = dev_get_priv(dev); ++ int ret; ++ ++ ret = pmic_reg_read(dev->parent, desc->pins[pin]); ++ if (ret < 0) ++ return ret; ++ ++ ret &= AXP_GPIO_CTRL_MASK; ++ if (ret == desc->input_mux) ++ return GPIOF_INPUT; ++ if (ret == AXP_GPIO_CTRL_OUTPUT_HIGH || ret == AXP_GPIO_CTRL_OUTPUT_LOW) ++ return GPIOF_OUTPUT; ++ ++ return GPIOF_UNKNOWN; ++} ++ + static int axp_gpio_set_flags(struct udevice *dev, unsigned pin, ulong flags) + { + const struct axp_gpio_desc *desc = dev_get_priv(dev); +@@ -60,6 +78,7 @@ static int axp_gpio_set_flags(struct ude + + static const struct dm_gpio_ops axp_gpio_ops = { + .get_value = axp_gpio_get_value, ++ .get_function = axp_gpio_get_function, + .xlate = gpio_xlate_offs_flags, + .set_flags = axp_gpio_set_flags, + }; diff --git a/package/boot/uboot-d1/patches/0052-gpio-axp-Add-pull-down-support-for-AXP22x-AXP8xx-var.patch b/package/boot/uboot-d1/patches/0052-gpio-axp-Add-pull-down-support-for-AXP22x-AXP8xx-var.patch new file mode 100644 index 00000000000000..771e5c3866c69c --- /dev/null +++ b/package/boot/uboot-d1/patches/0052-gpio-axp-Add-pull-down-support-for-AXP22x-AXP8xx-var.patch @@ -0,0 +1,56 @@ +From 4be9f9082b0a2ac2626ae20b7e07006139827442 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 28 Aug 2021 00:34:54 -0500 +Subject: [PATCH 52/90] gpio: axp: Add pull-down support for AXP22x/AXP8xx + variant + +The AXP221 and newer PMICs support a pull-down function on their GPIOs. +Add support for it. + +Signed-off-by: Samuel Holland +--- + drivers/gpio/axp_gpio.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -24,6 +24,7 @@ struct axp_gpio_desc { + u8 npins; + u8 status_reg; + u8 status_offset; ++ u8 pull_reg; + u8 input_mux; + }; + +@@ -60,11 +61,22 @@ static int axp_gpio_get_function(struct + static int axp_gpio_set_flags(struct udevice *dev, unsigned pin, ulong flags) + { + const struct axp_gpio_desc *desc = dev_get_priv(dev); ++ bool pull_down = flags & GPIOD_PULL_DOWN; ++ int ret; + u8 mux; + +- if (flags & (GPIOD_MASK_DSTYPE | GPIOD_MASK_PULL)) ++ if (flags & (GPIOD_MASK_DSTYPE | GPIOD_PULL_UP)) ++ return -EINVAL; ++ if (pull_down && !desc->pull_reg) + return -EINVAL; + ++ if (desc->pull_reg) { ++ ret = pmic_clrsetbits(dev->parent, desc->pull_reg, ++ BIT(pin), pull_down ? BIT(pin) : 0); ++ if (ret) ++ return ret; ++ } ++ + if (flags & GPIOD_IS_IN) + mux = desc->input_mux; + else if (flags & GPIOD_IS_OUT_ACTIVE) +@@ -129,6 +141,7 @@ static const struct axp_gpio_desc axp221 + .pins = axp221_gpio_pins, + .npins = ARRAY_SIZE(axp221_gpio_pins), + .status_reg = 0x94, ++ .pull_reg = 0x97, + .input_mux = 2, + }; + diff --git a/package/boot/uboot-d1/patches/0053-gpio-axp-Report-the-correct-value-for-outputs.patch b/package/boot/uboot-d1/patches/0053-gpio-axp-Report-the-correct-value-for-outputs.patch new file mode 100644 index 00000000000000..a6d0eb4526e8bd --- /dev/null +++ b/package/boot/uboot-d1/patches/0053-gpio-axp-Report-the-correct-value-for-outputs.patch @@ -0,0 +1,28 @@ +From 52c172782d659750b447572281cd11835d1edf58 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 31 Jul 2022 18:19:39 -0500 +Subject: [PATCH 53/90] gpio: axp: Report the correct value for outputs + +Signed-off-by: Samuel Holland +--- + drivers/gpio/axp_gpio.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/gpio/axp_gpio.c ++++ b/drivers/gpio/axp_gpio.c +@@ -33,6 +33,15 @@ static int axp_gpio_get_value(struct ude + const struct axp_gpio_desc *desc = dev_get_priv(dev); + int ret; + ++ ret = pmic_reg_read(dev->parent, desc->pins[pin]); ++ if (ret < 0) ++ return ret; ++ ++ if (ret == AXP_GPIO_CTRL_OUTPUT_LOW) ++ return 0; ++ if (ret == AXP_GPIO_CTRL_OUTPUT_HIGH) ++ return 1; ++ + ret = pmic_reg_read(dev->parent, desc->status_reg); + if (ret < 0) + return ret; diff --git a/package/boot/uboot-d1/patches/0054-sunxi-Fix-default-enablement-of-USB-host-drivers.patch b/package/boot/uboot-d1/patches/0054-sunxi-Fix-default-enablement-of-USB-host-drivers.patch new file mode 100644 index 00000000000000..52825dce21e62b --- /dev/null +++ b/package/boot/uboot-d1/patches/0054-sunxi-Fix-default-enablement-of-USB-host-drivers.patch @@ -0,0 +1,47 @@ +From 64de4fd71d35c6154a0f7b4c7c02cb24e978a4ce Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:45:19 -0500 +Subject: [PATCH 54/90] sunxi: Fix default-enablement of USB host drivers + +We tried to enable USB_EHCI_GENERIC and USB_OHCI_GENERIC by default. +This did not work because those symbols depend on USB_EHCI_HCD and +USB_OHCI_HCD, which were not enabled. Fix this by implying all four. + +Signed-off-by: Samuel Holland +--- + arch/arm/Kconfig | 4 ++++ + drivers/usb/host/Kconfig | 2 -- + 2 files changed, 4 insertions(+), 2 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1142,7 +1142,11 @@ config ARCH_SUNXI + imply SYSRESET + imply SYSRESET_WATCHDOG + imply SYSRESET_WATCHDOG_AUTO ++ imply USB_EHCI_GENERIC ++ imply USB_EHCI_HCD + imply USB_GADGET ++ imply USB_OHCI_GENERIC ++ imply USB_OHCI_HCD + imply WDT + + config ARCH_U8500 +--- a/drivers/usb/host/Kconfig ++++ b/drivers/usb/host/Kconfig +@@ -281,7 +281,6 @@ config USB_EHCI_ZYNQ + config USB_EHCI_GENERIC + bool "Support for generic EHCI USB controller" + depends on DM_USB +- default ARCH_SUNXI + ---help--- + Enables support for generic EHCI controller. + +@@ -343,7 +342,6 @@ config USB_OHCI_PCI + + config USB_OHCI_GENERIC + bool "Support for generic OHCI USB controller" +- default ARCH_SUNXI + ---help--- + Enables support for generic OHCI controller. + diff --git a/package/boot/uboot-d1/patches/0055-sunxi-Remove-unnecessary-Kconfig-selections.patch b/package/boot/uboot-d1/patches/0055-sunxi-Remove-unnecessary-Kconfig-selections.patch new file mode 100644 index 00000000000000..6fd4ffdae330b6 --- /dev/null +++ b/package/boot/uboot-d1/patches/0055-sunxi-Remove-unnecessary-Kconfig-selections.patch @@ -0,0 +1,36 @@ +From 891fef47500dbf4aecb16e08c1d8ade3fbc8caec Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 4 Aug 2022 23:22:05 -0500 +Subject: [PATCH 55/90] sunxi: Remove unnecessary Kconfig selections + +Two of these selections are redundant and have no effect: + - DM_KEYBOARD is selected by USB_KEYBOARD + - DM_MMC is selected by MMC + +This selection has no effect by default and is unnecessarily strong: + - USB_STORAGE is implied by DISTRO_DEFAULTS + +Signed-off-by: Samuel Holland +--- + arch/arm/Kconfig | 3 --- + 1 file changed, 3 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1100,8 +1100,6 @@ config ARCH_SUNXI + select DM_I2C if I2C + select DM_SPI if SPI + select DM_SPI_FLASH if SPI +- select DM_KEYBOARD +- select DM_MMC if MMC + select DM_SCSI if SCSI + select DM_SERIAL + select GPIO_EXTRA_HEADER +@@ -1119,7 +1117,6 @@ config ARCH_SUNXI + select SYS_THUMB_BUILD if !ARM64 + select USB if DISTRO_DEFAULTS + select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST +- select USB_STORAGE if DISTRO_DEFAULTS && USB_HOST + select SPL_USE_TINY_PRINTF + select USE_PREBOOT + select SYS_RELOC_GD_ENV_ADDR diff --git a/package/boot/uboot-d1/patches/0056-sunxi-Add-missing-dependencies-to-Kconfig-selections.patch b/package/boot/uboot-d1/patches/0056-sunxi-Add-missing-dependencies-to-Kconfig-selections.patch new file mode 100644 index 00000000000000..6adeeaef2b3e26 --- /dev/null +++ b/package/boot/uboot-d1/patches/0056-sunxi-Add-missing-dependencies-to-Kconfig-selections.patch @@ -0,0 +1,55 @@ +From 9e12a7fd80276092da3a43b7dbaf572bad294419 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 4 Aug 2022 23:29:13 -0500 +Subject: [PATCH 56/90] sunxi: Add missing dependencies to Kconfig selections + +Some of the selected symbols have a user-visible dependency. Make the +selections conditional on that dependency to avoid creating invalid +configurations. + +Signed-off-by: Samuel Holland +--- + arch/arm/Kconfig | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1090,30 +1090,30 @@ config ARCH_SOCFPGA + config ARCH_SUNXI + bool "Support sunxi (Allwinner) SoCs" + select BINMAN +- select CMD_GPIO ++ select CMD_GPIO if GPIO + select CMD_MMC if MMC + select CMD_USB if DISTRO_DEFAULTS && USB_HOST + select CLK + select DM +- select DM_ETH +- select DM_GPIO ++ select DM_ETH if NET ++ select DM_GPIO if GPIO + select DM_I2C if I2C ++ select DM_SCSI if BLK && SCSI ++ select DM_SERIAL if SERIAL + select DM_SPI if SPI + select DM_SPI_FLASH if SPI +- select DM_SCSI if SCSI +- select DM_SERIAL + select GPIO_EXTRA_HEADER + select OF_BOARD_SETUP + select OF_CONTROL + select OF_SEPARATE + select PINCTRL +- select SPECIFY_CONSOLE_INDEX ++ select SPECIFY_CONSOLE_INDEX if SERIAL + select SPL_SEPARATE_BSS if SPL + select SPL_STACK_R if SPL + select SPL_SYS_MALLOC_SIMPLE if SPL + select SPL_SYS_THUMB_BUILD if !ARM64 +- select SUNXI_GPIO +- select SYS_NS16550 ++ select SUNXI_GPIO if GPIO ++ select SYS_NS16550 if SERIAL + select SYS_THUMB_BUILD if !ARM64 + select USB if DISTRO_DEFAULTS + select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST diff --git a/package/boot/uboot-d1/patches/0057-sunxi-Hide-image-type-selection-if-SPL-is-disabled.patch b/package/boot/uboot-d1/patches/0057-sunxi-Hide-image-type-selection-if-SPL-is-disabled.patch new file mode 100644 index 00000000000000..314720197e14dd --- /dev/null +++ b/package/boot/uboot-d1/patches/0057-sunxi-Hide-image-type-selection-if-SPL-is-disabled.patch @@ -0,0 +1,22 @@ +From 2ba626d36e622f29528ce953618dde9a01bdacd6 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 21:56:43 -0500 +Subject: [PATCH 57/90] sunxi: Hide image type selection if SPL is disabled + +This choice is meaningless when SPL is disabled. Hide it to avoid any +possible confusion. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -1,5 +1,6 @@ + choice + prompt "SPL Image Type" ++ depends on SPL + default SPL_IMAGE_TYPE_SUNXI_EGON + + config SPL_IMAGE_TYPE_SUNXI_EGON diff --git a/package/boot/uboot-d1/patches/0058-sunxi-Share-the-board-Kconfig-across-architectures.patch b/package/boot/uboot-d1/patches/0058-sunxi-Share-the-board-Kconfig-across-architectures.patch new file mode 100644 index 00000000000000..dfae082cf5c85f --- /dev/null +++ b/package/boot/uboot-d1/patches/0058-sunxi-Share-the-board-Kconfig-across-architectures.patch @@ -0,0 +1,75 @@ +From 5d197433cd54085306e369ac260e09fe6077bfbb Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 4 Aug 2022 21:30:57 -0500 +Subject: [PATCH 58/90] sunxi: Share the board Kconfig across architectures + +With the introduction of the Allwinner D1, the sunxi board family now +spans multiple architectures (ARM and RISC-V). Since ARCH_SUNXI depends +on ARM, it cannot be used to gate architecture-independent options. +Specifically, this means the board Kconfig file cannot be sourced from +inside the "if ARCH_SUNXI" block. + +Introduce a new BOARD_SUNXI symbol that can be selected by both +ARCH_SUNXI now and the new RISC-V SoC symbols when they are added, and +use it to gate the architecture-independent board options. + +Signed-off-by: Samuel Holland +--- + arch/Kconfig | 1 + + arch/arm/Kconfig | 1 + + arch/arm/mach-sunxi/Kconfig | 2 -- + board/sunxi/Kconfig | 11 +++++++++++ + 4 files changed, 13 insertions(+), 2 deletions(-) + +--- a/arch/Kconfig ++++ b/arch/Kconfig +@@ -482,6 +482,7 @@ source "arch/Kconfig.nxp" + endif + + source "board/keymile/Kconfig" ++source "board/sunxi/Kconfig" + + if MIPS || MICROBLAZE + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1090,6 +1090,7 @@ config ARCH_SOCFPGA + config ARCH_SUNXI + bool "Support sunxi (Allwinner) SoCs" + select BINMAN ++ select BOARD_SUNXI + select CMD_GPIO if GPIO + select CMD_MMC if MMC + select CMD_USB if DISTRO_DEFAULTS && USB_HOST +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -959,8 +959,6 @@ config BLUETOOTH_DT_DEVICE_FIXUP + The used address is "bdaddr" if set, and "ethaddr" with the LSB + flipped elsewise. + +-source "board/sunxi/Kconfig" +- + endif + + config CHIP_DIP_SCAN +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -1,3 +1,10 @@ ++config BOARD_SUNXI ++ bool ++ ++if BOARD_SUNXI ++ ++menu "sunxi board options" ++ + choice + prompt "SPL Image Type" + depends on SPL +@@ -23,3 +30,7 @@ config SPL_IMAGE_TYPE + string + default "sunxi_egon" if SPL_IMAGE_TYPE_SUNXI_EGON + default "sunxi_toc0" if SPL_IMAGE_TYPE_SUNXI_TOC0 ++ ++endmenu ++ ++endif diff --git a/package/boot/uboot-d1/patches/0059-sunxi-Move-most-Kconfig-selections-to-the-board-Kcon.patch b/package/boot/uboot-d1/patches/0059-sunxi-Move-most-Kconfig-selections-to-the-board-Kcon.patch new file mode 100644 index 00000000000000..e576d137e83c16 --- /dev/null +++ b/package/boot/uboot-d1/patches/0059-sunxi-Move-most-Kconfig-selections-to-the-board-Kcon.patch @@ -0,0 +1,140 @@ +From 963331be1cc924ad7c928f88b3ee46bc20a41bcd Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 18:06:20 +0000 +Subject: [PATCH 59/90] sunxi: Move most Kconfig selections to the board + Kconfig + +To maintain consistent behavior across architectures, most of the +options selected by ARCH_SUNXI should be selected for the D1 SoC as +well. To accomplish this, select them from BOARD_SUNXI instead. + +No functional change here. Lines are only moved and alphabetized. + +Signed-off-by: Samuel Holland + +Signed-off-by: Zoltan HERPAI +--- + arch/arm/Kconfig | 47 --------------------------------------------- + board/sunxi/Kconfig | 46 ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 46 insertions(+), 47 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1089,63 +1089,16 @@ config ARCH_SOCFPGA + + config ARCH_SUNXI + bool "Support sunxi (Allwinner) SoCs" +- select BINMAN + select BOARD_SUNXI +- select CMD_GPIO if GPIO +- select CMD_MMC if MMC +- select CMD_USB if DISTRO_DEFAULTS && USB_HOST +- select CLK +- select DM +- select DM_ETH if NET +- select DM_GPIO if GPIO +- select DM_I2C if I2C +- select DM_SCSI if BLK && SCSI +- select DM_SERIAL if SERIAL +- select DM_SPI if SPI +- select DM_SPI_FLASH if SPI + select GPIO_EXTRA_HEADER +- select OF_BOARD_SETUP + select OF_CONTROL + select OF_SEPARATE +- select PINCTRL + select SPECIFY_CONSOLE_INDEX if SERIAL +- select SPL_SEPARATE_BSS if SPL + select SPL_STACK_R if SPL + select SPL_SYS_MALLOC_SIMPLE if SPL + select SPL_SYS_THUMB_BUILD if !ARM64 +- select SUNXI_GPIO if GPIO +- select SYS_NS16550 if SERIAL + select SYS_THUMB_BUILD if !ARM64 +- select USB if DISTRO_DEFAULTS +- select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST + select SPL_USE_TINY_PRINTF +- select USE_PREBOOT +- select SYS_RELOC_GD_ENV_ADDR +- imply BOARD_LATE_INIT +- imply CMD_DM +- imply CMD_GPT +- imply CMD_UBI if MTD_RAW_NAND +- imply DISTRO_DEFAULTS +- imply FAT_WRITE +- imply FIT +- imply OF_LIBFDT_OVERLAY +- imply PRE_CONSOLE_BUFFER +- imply SPL_GPIO +- imply SPL_LIBCOMMON_SUPPORT +- imply SPL_LIBGENERIC_SUPPORT +- imply SPL_LOAD_FIT +- imply SPL_MMC if MMC +- imply SPL_POWER +- imply SPL_SERIAL +- imply SYSRESET +- imply SYSRESET_WATCHDOG +- imply SYSRESET_WATCHDOG_AUTO +- imply USB_EHCI_GENERIC +- imply USB_EHCI_HCD +- imply USB_GADGET +- imply USB_OHCI_GENERIC +- imply USB_OHCI_HCD +- imply WDT + + config ARCH_U8500 + bool "ST-Ericsson U8500 Series" +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -1,5 +1,51 @@ + config BOARD_SUNXI + bool ++ select BINMAN ++ select CLK ++ select CMD_GPIO if GPIO ++ select CMD_MMC if MMC ++ select CMD_USB if DISTRO_DEFAULTS && USB_HOST ++ select DM ++ select DM_ETH if NET ++ select DM_GPIO if GPIO ++ select DM_I2C if I2C ++ select DM_SCSI if BLK && SCSI ++ select DM_SERIAL if SERIAL ++ select DM_SPI if SPI ++ select DM_SPI_FLASH if SPI ++ select OF_BOARD_SETUP ++ select PINCTRL ++ select SPL_SEPARATE_BSS if SPL ++ select SUNXI_GPIO if GPIO ++ select SYS_NS16550 if SERIAL ++ select SYS_RELOC_GD_ENV_ADDR ++ select USB if DISTRO_DEFAULTS ++ select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST ++ select USE_PREBOOT ++ imply BOARD_LATE_INIT ++ imply CMD_DM ++ imply CMD_GPT ++ imply CMD_UBI if MTD_RAW_NAND ++ imply DISTRO_DEFAULTS ++ imply FAT_WRITE ++ imply FIT ++ imply OF_LIBFDT_OVERLAY ++ imply PRE_CONSOLE_BUFFER ++ imply SPL_GPIO ++ imply SPL_LIBCOMMON_SUPPORT ++ imply SPL_LIBGENERIC_SUPPORT ++ imply SPL_MMC if MMC ++ imply SPL_POWER ++ imply SPL_SERIAL ++ imply SYSRESET ++ imply SYSRESET_WATCHDOG ++ imply SYSRESET_WATCHDOG_AUTO ++ imply USB_EHCI_GENERIC ++ imply USB_EHCI_HCD ++ imply USB_GADGET ++ imply USB_OHCI_GENERIC ++ imply USB_OHCI_HCD ++ imply WDT + + if BOARD_SUNXI + diff --git a/package/boot/uboot-d1/patches/0060-sunxi-Globally-enable-SUPPORT_SPL.patch b/package/boot/uboot-d1/patches/0060-sunxi-Globally-enable-SUPPORT_SPL.patch new file mode 100644 index 00000000000000..0b59906f440c91 --- /dev/null +++ b/package/boot/uboot-d1/patches/0060-sunxi-Globally-enable-SUPPORT_SPL.patch @@ -0,0 +1,147 @@ +From 5838fd3a53e613312d46ab4cb6015a502c4c45d0 Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 18:07:24 +0000 +Subject: [PATCH 60/90] sunxi: Globally enable SUPPORT_SPL + +This was already supported by every machine type. It is unlikely that +any new SoC support will be added without SPL support. + +Signed-off-by: Samuel Holland +Signed-off-by: Zoltan HERPAI +--- + arch/arm/mach-sunxi/Kconfig | 14 -------------- + board/sunxi/Kconfig | 2 ++ + 2 files changed, 2 insertions(+), 14 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -133,7 +133,6 @@ config SUN50I_GEN_H6 + select FIT + select SPL_LOAD_FIT + select MMC_SUNXI_HAS_NEW_MODE +- select SUPPORT_SPL + ---help--- + Select this for sunxi SoCs which have H6 like peripherals, clocks + and memory map. +@@ -166,7 +165,6 @@ config MACH_SUNXI_H3_H5 + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_32BIT + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + + # TODO: try out A80's 8GiB DRAM space + config SUNXI_DRAM_MAX_SIZE +@@ -183,7 +181,6 @@ config MACH_SUNIV + bool "suniv (Allwinner F1C100s/F1C200s/F1C600/R6)" + select CPU_ARM926EJS + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + select SKIP_LOWLEVEL_INIT_ONLY + select SPL_SKIP_LOWLEVEL_INIT_ONLY + +@@ -192,7 +189,6 @@ config MACH_SUN4I + select CPU_V7A + select DRAM_SUN4I + select SUNXI_GEN_SUN4I +- select SUPPORT_SPL + imply SPL_SYS_I2C_LEGACY + imply SYS_I2C_LEGACY + +@@ -201,7 +197,6 @@ config MACH_SUN5I + select CPU_V7A + select DRAM_SUN4I + select SUNXI_GEN_SUN4I +- select SUPPORT_SPL + imply SPL_SYS_I2C_LEGACY + imply SYS_I2C_LEGACY + +@@ -216,7 +211,6 @@ config MACH_SUN6I + select SPL_I2C + select SUN6I_PRCM + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + select SYS_I2C_SUN6I_P2WI + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + +@@ -229,7 +223,6 @@ config MACH_SUN7I + select SPL_ARMV7_SET_CORTEX_SMPEN + select DRAM_SUN4I + select SUNXI_GEN_SUN4I +- select SUPPORT_SPL + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + imply SPL_SYS_I2C_LEGACY + imply SYS_I2C_LEGACY +@@ -243,7 +236,6 @@ config MACH_SUN8I_A23 + select DRAM_SUN8I_A23 + select SPL_I2C + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + select SYS_I2C_SUN8I_RSB + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + +@@ -256,7 +248,6 @@ config MACH_SUN8I_A33 + select DRAM_SUN8I_A33 + select SPL_I2C + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + select SYS_I2C_SUN8I_RSB + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + +@@ -268,7 +259,6 @@ config MACH_SUN8I_A83T + select SUNXI_GEN_SUN6I + select MMC_SUNXI_HAS_NEW_MODE + select MMC_SUNXI_HAS_MODE_SWITCH +- select SUPPORT_SPL + select SYS_I2C_SUN8I_RSB + + config MACH_SUN8I_H3 +@@ -288,7 +278,6 @@ config MACH_SUN8I_R40 + select ARCH_SUPPORT_PSCI + select SUNXI_GEN_SUN6I + select MMC_SUNXI_HAS_NEW_MODE +- select SUPPORT_SPL + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_32BIT + imply SPL_SYS_I2C_LEGACY +@@ -302,7 +291,6 @@ config MACH_SUN8I_V3S + select SUNXI_GEN_SUN6I + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_16BIT +- select SUPPORT_SPL + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + + config MACH_SUN9I +@@ -313,7 +301,6 @@ config MACH_SUN9I + select SPL_I2C + select SUN6I_PRCM + select SUNXI_GEN_SUN6I +- select SUPPORT_SPL + + config MACH_SUN50I + bool "sun50i (Allwinner A64)" +@@ -322,7 +309,6 @@ config MACH_SUN50I + select SUNXI_DE2 + select SUNXI_GEN_SUN6I + select MMC_SUNXI_HAS_NEW_MODE +- select SUPPORT_SPL + select SUNXI_DRAM_DW + select SUNXI_DRAM_DW_32BIT + select FIT +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -18,6 +18,7 @@ config BOARD_SUNXI + select SPL_SEPARATE_BSS if SPL + select SUNXI_GPIO if GPIO + select SYS_NS16550 if SERIAL ++ select SUPPORT_SPL + select SYS_RELOC_GD_ENV_ADDR + select USB if DISTRO_DEFAULTS + select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST +@@ -31,6 +32,7 @@ config BOARD_SUNXI + imply FIT + imply OF_LIBFDT_OVERLAY + imply PRE_CONSOLE_BUFFER ++ imply SPL + imply SPL_GPIO + imply SPL_LIBCOMMON_SUPPORT + imply SPL_LIBGENERIC_SUPPORT diff --git a/package/boot/uboot-d1/patches/0061-sunxi-Downgrade-driver-selections-to-implications.patch b/package/boot/uboot-d1/patches/0061-sunxi-Downgrade-driver-selections-to-implications.patch new file mode 100644 index 00000000000000..e77c5cb080fa4f --- /dev/null +++ b/package/boot/uboot-d1/patches/0061-sunxi-Downgrade-driver-selections-to-implications.patch @@ -0,0 +1,33 @@ +From 6c8707fcd3372015829a1e8b8d5e8030c5806382 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:10:46 -0500 +Subject: [PATCH 61/90] sunxi: Downgrade driver selections to implications + +While not especially likely, it is plausible that someone wants to build +U-Boot without GPIO or UART support. Don't force building these drivers. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -16,8 +16,6 @@ config BOARD_SUNXI + select OF_BOARD_SETUP + select PINCTRL + select SPL_SEPARATE_BSS if SPL +- select SUNXI_GPIO if GPIO +- select SYS_NS16550 if SERIAL + select SUPPORT_SPL + select SYS_RELOC_GD_ENV_ADDR + select USB if DISTRO_DEFAULTS +@@ -39,6 +37,8 @@ config BOARD_SUNXI + imply SPL_MMC if MMC + imply SPL_POWER + imply SPL_SERIAL ++ imply SUNXI_GPIO ++ imply SYS_NS16550 + imply SYSRESET + imply SYSRESET_WATCHDOG + imply SYSRESET_WATCHDOG_AUTO diff --git a/package/boot/uboot-d1/patches/0062-sunxi-Enable-the-I2C-driver-by-default.patch b/package/boot/uboot-d1/patches/0062-sunxi-Enable-the-I2C-driver-by-default.patch new file mode 100644 index 00000000000000..e6d963e812a888 --- /dev/null +++ b/package/boot/uboot-d1/patches/0062-sunxi-Enable-the-I2C-driver-by-default.patch @@ -0,0 +1,23 @@ +From ad619478827b825d7b88dce22eb9b5e1c6ea7eb0 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:11:54 -0500 +Subject: [PATCH 62/90] sunxi: Enable the I2C driver by default + +This is used by quite a large number of boards, for PMIC/regulator or +LCD panel control. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -38,6 +38,7 @@ config BOARD_SUNXI + imply SPL_POWER + imply SPL_SERIAL + imply SUNXI_GPIO ++ imply SYS_I2C_MVTWSI + imply SYS_NS16550 + imply SYSRESET + imply SYSRESET_WATCHDOG diff --git a/package/boot/uboot-d1/patches/0063-sunxi-Move-default-values-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0063-sunxi-Move-default-values-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..17bf8cb3ace5ed --- /dev/null +++ b/package/boot/uboot-d1/patches/0063-sunxi-Move-default-values-to-the-board-Kconfig.patch @@ -0,0 +1,190 @@ +From fde804c2ece090eb7802a218781e38c7c6d6f00d Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:10:11 -0500 +Subject: [PATCH 63/90] sunxi: Move default values to the board Kconfig + +This keeps all of the defaults for sunxi platforms in one place. Most of +these only depend on architecture-independent features of the SoC (clock +tree or SRAM layout) anyway. + +No functional change; just some minor help text cleanup. + +Signed-off-by: Samuel Holland +--- + arch/arm/mach-sunxi/Kconfig | 67 ------------------------------------ + board/sunxi/Kconfig | 68 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 68 insertions(+), 67 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -1,8 +1,5 @@ + if ARCH_SUNXI + +-config IDENT_STRING +- default " Allwinner Technology" +- + config DRAM_SUN4I + bool + help +@@ -99,17 +96,6 @@ config AXP_PMIC_BUS + Select this PMIC bus access helpers for Sunxi platform PRCM or other + AXP family PMIC devices. + +-config SUNXI_SRAM_ADDRESS +- hex +- default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 +- default 0x20000 if SUN50I_GEN_H6 +- default 0x0 +- ---help--- +- Older Allwinner SoCs have their mask boot ROM mapped just below 4GB, +- with the first SRAM region being located at address 0. +- Some newer SoCs map the boot ROM at address 0 instead and move the +- SRAM to a different address. +- + config SUNXI_A64_TIMER_ERRATUM + bool + +@@ -562,48 +548,6 @@ config DRAM_ODT_CORRECTION + then the correction is negative. Usually the value for this is 0. + endif + +-config SYS_CLK_FREQ +- default 408000000 if MACH_SUNIV +- default 1008000000 if MACH_SUN4I +- default 1008000000 if MACH_SUN5I +- default 1008000000 if MACH_SUN6I +- default 912000000 if MACH_SUN7I +- default 816000000 if MACH_SUN50I || MACH_SUN50I_H5 +- default 1008000000 if MACH_SUN8I +- default 1008000000 if MACH_SUN9I +- default 888000000 if MACH_SUN50I_H6 +- default 1008000000 if MACH_SUN50I_H616 +- +-config SYS_CONFIG_NAME +- default "suniv" if MACH_SUNIV +- default "sun4i" if MACH_SUN4I +- default "sun5i" if MACH_SUN5I +- default "sun6i" if MACH_SUN6I +- default "sun7i" if MACH_SUN7I +- default "sun8i" if MACH_SUN8I +- default "sun9i" if MACH_SUN9I +- default "sun50i" if MACH_SUN50I +- default "sun50i" if MACH_SUN50I_H6 +- default "sun50i" if MACH_SUN50I_H616 +- +-config SYS_BOARD +- default "sunxi" +- +-config SYS_SOC +- default "sunxi" +- +-config SUNXI_MINIMUM_DRAM_MB +- int "minimum DRAM size" +- default 32 if MACH_SUNIV +- default 64 if MACH_SUN8I_V3S +- default 256 +- ---help--- +- Minimum DRAM size expected on the board. Traditionally we assumed +- 256 MB, so that U-Boot would load at 160MB. With co-packaged DRAM +- we have smaller sizes, though, so that U-Boot's own load address and +- the default payload addresses must be shifted down. +- This is expected to be fixed by the SoC selection. +- + config UART0_PORT_F + bool "UART0 on MicroSD breakout board" + ---help--- +@@ -898,17 +842,6 @@ config GMAC_TX_DELAY + ---help--- + Set the GMAC Transmit Clock Delay Chain value. + +-config SPL_STACK_R_ADDR +- default 0x81e00000 if MACH_SUNIV +- default 0x4fe00000 if MACH_SUN4I +- default 0x4fe00000 if MACH_SUN5I +- default 0x4fe00000 if MACH_SUN6I +- default 0x4fe00000 if MACH_SUN7I +- default 0x4fe00000 if MACH_SUN8I +- default 0x2fe00000 if MACH_SUN9I +- default 0x4fe00000 if MACH_SUN50I +- default 0x4fe00000 if SUN50I_GEN_H6 +- + config SPL_SPI_SUNXI + bool "Support for SPI Flash on Allwinner SoCs in SPL" + depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_R40 || SUN50I_GEN_H6 || MACH_SUNIV +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -52,6 +52,74 @@ config BOARD_SUNXI + + if BOARD_SUNXI + ++config IDENT_STRING ++ default " Allwinner Technology" ++ ++config SPL_STACK_R_ADDR ++ default 0x81e00000 if MACH_SUNIV ++ default 0x4fe00000 if MACH_SUN4I ++ default 0x4fe00000 if MACH_SUN5I ++ default 0x4fe00000 if MACH_SUN6I ++ default 0x4fe00000 if MACH_SUN7I ++ default 0x4fe00000 if MACH_SUN8I ++ default 0x2fe00000 if MACH_SUN9I ++ default 0x4fe00000 if MACH_SUN50I ++ default 0x4fe00000 if SUN50I_GEN_H6 ++ ++config SUNXI_MINIMUM_DRAM_MB ++ int "minimum DRAM size" ++ default 32 if MACH_SUNIV ++ default 64 if MACH_SUN8I_V3S ++ default 256 ++ help ++ Minimum DRAM size expected on the board. Traditionally we ++ assumed 256 MB, so that U-Boot would load at 160MB. With ++ co-packaged DRAM we have smaller sizes, though, so U-Boot's ++ own load address and the default payload addresses must be ++ shifted down. This is expected to be fixed by the SoC ++ selection. ++ ++config SUNXI_SRAM_ADDRESS ++ hex ++ default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 ++ default 0x20000 if SUN50I_GEN_H6 ++ default 0x0 ++ help ++ Older Allwinner SoCs have their boot mask ROM mapped just ++ below 4GB, with the first SRAM region located at address 0. ++ Newer SoCs map the boot ROM at address 0 instead and move the ++ SRAM to a different address. ++ ++config SYS_BOARD ++ default "sunxi" ++ ++config SYS_CLK_FREQ ++ default 408000000 if MACH_SUNIV ++ default 1008000000 if MACH_SUN4I ++ default 1008000000 if MACH_SUN5I ++ default 1008000000 if MACH_SUN6I ++ default 912000000 if MACH_SUN7I ++ default 1008000000 if MACH_SUN8I ++ default 1008000000 if MACH_SUN9I ++ default 816000000 if MACH_SUN50I || MACH_SUN50I_H5 ++ default 888000000 if MACH_SUN50I_H6 ++ default 1008000000 if MACH_SUN50I_H616 ++ ++config SYS_CONFIG_NAME ++ default "suniv" if MACH_SUNIV ++ default "sun4i" if MACH_SUN4I ++ default "sun5i" if MACH_SUN5I ++ default "sun6i" if MACH_SUN6I ++ default "sun7i" if MACH_SUN7I ++ default "sun8i" if MACH_SUN8I ++ default "sun9i" if MACH_SUN9I ++ default "sun50i" if MACH_SUN50I ++ default "sun50i" if MACH_SUN50I_H6 ++ default "sun50i" if MACH_SUN50I_H616 ++ ++config SYS_SOC ++ default "sunxi" ++ + menu "sunxi board options" + + choice diff --git a/package/boot/uboot-d1/patches/0064-sunxi-Hide-the-SUNXI_MINIMUM_DRAM_MB-symbol.patch b/package/boot/uboot-d1/patches/0064-sunxi-Hide-the-SUNXI_MINIMUM_DRAM_MB-symbol.patch new file mode 100644 index 00000000000000..76486485971bd2 --- /dev/null +++ b/package/boot/uboot-d1/patches/0064-sunxi-Hide-the-SUNXI_MINIMUM_DRAM_MB-symbol.patch @@ -0,0 +1,24 @@ +From 8377aa2162d0a7fda76597eae59725a298dda5e6 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 31 Oct 2022 22:14:36 -0500 +Subject: [PATCH 64/90] sunxi: Hide the SUNXI_MINIMUM_DRAM_MB symbol + +This option affects the ABI between SPL/U-Boot and U-Boot/scripts, so it +should not normally be changed by the user. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -67,7 +67,7 @@ config SPL_STACK_R_ADDR + default 0x4fe00000 if SUN50I_GEN_H6 + + config SUNXI_MINIMUM_DRAM_MB +- int "minimum DRAM size" ++ int + default 32 if MACH_SUNIV + default 64 if MACH_SUN8I_V3S + default 256 diff --git a/package/boot/uboot-d1/patches/0065-sunxi-Clean-up-the-SPL_STACK_R_ADDR-defaults.patch b/package/boot/uboot-d1/patches/0065-sunxi-Clean-up-the-SPL_STACK_R_ADDR-defaults.patch new file mode 100644 index 00000000000000..1a662bea2c32ab --- /dev/null +++ b/package/boot/uboot-d1/patches/0065-sunxi-Clean-up-the-SPL_STACK_R_ADDR-defaults.patch @@ -0,0 +1,33 @@ +From 41e5a94533e9744b8eac718dd2c359eca57573f8 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:25:26 -0500 +Subject: [PATCH 65/90] sunxi: Clean up the SPL_STACK_R_ADDR defaults + +Update this option to be based on SUNXI_MINIMUM_DRAM_MB. This corrects +the value used on V3s, which previously was the MACH_SUN8I default, and +so relied on addresses wrapping modulo the DRAM size. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -57,14 +57,9 @@ config IDENT_STRING + + config SPL_STACK_R_ADDR + default 0x81e00000 if MACH_SUNIV +- default 0x4fe00000 if MACH_SUN4I +- default 0x4fe00000 if MACH_SUN5I +- default 0x4fe00000 if MACH_SUN6I +- default 0x4fe00000 if MACH_SUN7I +- default 0x4fe00000 if MACH_SUN8I + default 0x2fe00000 if MACH_SUN9I +- default 0x4fe00000 if MACH_SUN50I +- default 0x4fe00000 if SUN50I_GEN_H6 ++ default 0x4fe00000 if SUNXI_MINIMUM_DRAM_MB >= 256 ++ default 0x43e00000 if SUNXI_MINIMUM_DRAM_MB >= 64 + + config SUNXI_MINIMUM_DRAM_MB + int diff --git a/package/boot/uboot-d1/patches/0066-sunxi-Move-PRE_CON_BUF_ADDR-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0066-sunxi-Move-PRE_CON_BUF_ADDR-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..daaf0b5fc60ddd --- /dev/null +++ b/package/boot/uboot-d1/patches/0066-sunxi-Move-PRE_CON_BUF_ADDR-to-the-board-Kconfig.patch @@ -0,0 +1,42 @@ +From e947c7377b90897e4c638dad6e64201361dc8a9e Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:45:10 -0500 +Subject: [PATCH 66/90] sunxi: Move PRE_CON_BUF_ADDR to the board Kconfig + +This provides a default value for RISC-V when that is added, and it +makes sense to put this option next to the other DRAM layout options. + +While at it, provide sensible values for platforms with less DRAM. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 6 ++++++ + common/Kconfig | 2 -- + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -55,6 +55,12 @@ if BOARD_SUNXI + config IDENT_STRING + default " Allwinner Technology" + ++config PRE_CON_BUF_ADDR ++ default 0x81000000 if MACH_SUNIV ++ default 0x2f000000 if MACH_SUN9I ++ default 0x4f000000 if SUNXI_MINIMUM_DRAM_MB >= 256 ++ default 0x43000000 if SUNXI_MINIMUM_DRAM_MB >= 64 ++ + config SPL_STACK_R_ADDR + default 0x81e00000 if MACH_SUNIV + default 0x2fe00000 if MACH_SUN9I +--- a/common/Kconfig ++++ b/common/Kconfig +@@ -195,8 +195,6 @@ config PRE_CON_BUF_SZ + config PRE_CON_BUF_ADDR + hex "Address of the pre-console buffer" + depends on PRE_CONSOLE_BUFFER +- default 0x2f000000 if ARCH_SUNXI && MACH_SUN9I +- default 0x4f000000 if ARCH_SUNXI && !MACH_SUN9I + default 0x0f000000 if ROCKCHIP_RK3288 + default 0x0f200000 if ROCKCHIP_RK3399 + help diff --git a/package/boot/uboot-d1/patches/0067-sunxi-Move-SPL_BSS_START_ADDR-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0067-sunxi-Move-SPL_BSS_START_ADDR-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..286b2b976b20f6 --- /dev/null +++ b/package/boot/uboot-d1/patches/0067-sunxi-Move-SPL_BSS_START_ADDR-to-the-board-Kconfig.patch @@ -0,0 +1,43 @@ +From 71796f9d47a6b7e0dd6bb276436950463039c1b8 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 31 Oct 2022 00:08:26 -0500 +Subject: [PATCH 67/90] sunxi: Move SPL_BSS_START_ADDR to the board Kconfig + +This provides a default value for RISC-V when that is added, and it +makes sense to put this option next to the other DRAM layout options. + +While at it, provide sensible values for platforms with less DRAM. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 6 ++++++ + common/spl/Kconfig | 3 --- + 2 files changed, 6 insertions(+), 3 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -61,6 +61,12 @@ config PRE_CON_BUF_ADDR + default 0x4f000000 if SUNXI_MINIMUM_DRAM_MB >= 256 + default 0x43000000 if SUNXI_MINIMUM_DRAM_MB >= 64 + ++config SPL_BSS_START_ADDR ++ default 0x81f80000 if MACH_SUNIV ++ default 0x2ff80000 if MACH_SUN9I ++ default 0x4ff80000 if SUNXI_MINIMUM_DRAM_MB >= 256 ++ default 0x43f80000 if SUNXI_MINIMUM_DRAM_MB >= 64 ++ + config SPL_STACK_R_ADDR + default 0x81e00000 if MACH_SUNIV + default 0x2fe00000 if MACH_SUN9I +--- a/common/spl/Kconfig ++++ b/common/spl/Kconfig +@@ -119,9 +119,6 @@ config SPL_BSS_START_ADDR + default 0x88200000 if (ARCH_MX6 && (MX6SX || MX6SL || MX6UL || MX6ULL)) || ARCH_MX7 + default 0x18200000 if ARCH_MX6 && !(MX6SX || MX6SL || MX6UL || MX6ULL) + default 0x80a00000 if ARCH_OMAP2PLUS +- default 0x81f80000 if ARCH_SUNXI && MACH_SUNIV +- default 0x4ff80000 if ARCH_SUNXI && !(MACH_SUN9I || MACH_SUNIV) +- default 0x2ff80000 if ARCH_SUNXI && MACH_SUN9I + default 0x1000 if ARCH_ZYNQMP + + choice diff --git a/package/boot/uboot-d1/patches/0068-sunxi-Move-SPL_TEXT_BASE-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0068-sunxi-Move-SPL_TEXT_BASE-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..77aa5929435261 --- /dev/null +++ b/package/boot/uboot-d1/patches/0068-sunxi-Move-SPL_TEXT_BASE-to-the-board-Kconfig.patch @@ -0,0 +1,39 @@ +From 5d60490d0f0ca0a5d414ba9a4e41ceea8a98b4d2 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:07:47 -0500 +Subject: [PATCH 68/90] sunxi: Move SPL_TEXT_BASE to the board Kconfig + +It makes sense to put this near the definition of SUNXI_SRAM_ADDRESS. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 5 +++++ + common/spl/Kconfig | 3 --- + 2 files changed, 5 insertions(+), 3 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -73,6 +73,11 @@ config SPL_STACK_R_ADDR + default 0x4fe00000 if SUNXI_MINIMUM_DRAM_MB >= 256 + default 0x43e00000 if SUNXI_MINIMUM_DRAM_MB >= 64 + ++config SPL_TEXT_BASE ++ default 0x10060 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 ++ default 0x20060 if SUN50I_GEN_H6 ++ default 0x00060 ++ + config SUNXI_MINIMUM_DRAM_MB + int + default 32 if MACH_SUNIV +--- a/common/spl/Kconfig ++++ b/common/spl/Kconfig +@@ -261,9 +261,6 @@ config SPL_TEXT_BASE + default 0x402F4000 if AM43XX + default 0x402F0400 if AM33XX + default 0x40301350 if OMAP54XX +- default 0x10060 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN9I +- default 0x20060 if SUN50I_GEN_H6 +- default 0x00060 if ARCH_SUNXI + default 0xfffc0000 if ARCH_ZYNQMP + default 0x0 + help diff --git a/package/boot/uboot-d1/patches/0069-sunxi-Move-SYS_LOAD_ADDR-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0069-sunxi-Move-SYS_LOAD_ADDR-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..3d6e3018daeca3 --- /dev/null +++ b/package/boot/uboot-d1/patches/0069-sunxi-Move-SYS_LOAD_ADDR-to-the-board-Kconfig.patch @@ -0,0 +1,40 @@ +From 03f3ba82e9dfb67f1ae0812f72aea6559aa61bb4 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:23:34 -0500 +Subject: [PATCH 69/90] sunxi: Move SYS_LOAD_ADDR to the board Kconfig + +This will provide a default value for RISC-V when that is added, and it +makes sense to put this option next to the other DRAM layout options. + +Signed-off-by: Samuel Holland +--- + Kconfig | 3 --- + board/sunxi/Kconfig | 5 +++++ + 2 files changed, 5 insertions(+), 3 deletions(-) + +--- a/Kconfig ++++ b/Kconfig +@@ -508,9 +508,6 @@ config SYS_LOAD_ADDR + hex "Address in memory to use by default" + default 0x01000000 if ARCH_SOCFPGA + default 0x02000000 if PPC || X86 +- default 0x81000000 if MACH_SUNIV +- default 0x22000000 if MACH_SUN9I +- default 0x42000000 if ARCH_SUNXI + default 0x82000000 if ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3 + default 0x82000000 if ARCH_MX6 && (MX6SL || MX6SLL || MX6SX || MX6UL || MX6ULL) + default 0x12000000 if ARCH_MX6 && !(MX6SL || MX6SLL || MX6SX || MX6UL || MX6ULL) +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -129,6 +129,11 @@ config SYS_CONFIG_NAME + default "sun50i" if MACH_SUN50I_H6 + default "sun50i" if MACH_SUN50I_H616 + ++config SYS_LOAD_ADDR ++ default 0x81000000 if MACH_SUNIV ++ default 0x22000000 if MACH_SUN9I ++ default 0x42000000 ++ + config SYS_SOC + default "sunxi" + diff --git a/package/boot/uboot-d1/patches/0070-sunxi-Move-TEXT_BASE-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0070-sunxi-Move-TEXT_BASE-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..910e02c0d27ed3 --- /dev/null +++ b/package/boot/uboot-d1/patches/0070-sunxi-Move-TEXT_BASE-to-the-board-Kconfig.patch @@ -0,0 +1,42 @@ +From 08b45a89c7b25eb7828589360cf4ca2d9910cc59 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 21:48:53 -0500 +Subject: [PATCH 70/90] sunxi: Move TEXT_BASE to the board Kconfig + +This is how the vast majority of platforms provided TEXT_BASE. +sunxi was the exception here. + +Signed-off-by: Samuel Holland +--- + board/sunxi/Kconfig | 6 ++++++ + boot/Kconfig | 4 ---- + 2 files changed, 6 insertions(+), 4 deletions(-) + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -137,6 +137,12 @@ config SYS_LOAD_ADDR + config SYS_SOC + default "sunxi" + ++config TEXT_BASE ++ default 0x81700000 if MACH_SUNIV ++ default 0x2a000000 if MACH_SUN9I ++ default 0x4a000000 if SUNXI_MINIMUM_DRAM_MB >= 256 ++ default 0x42e00000 if SUNXI_MINIMUM_DRAM_MB >= 64 ++ + menu "sunxi board options" + + choice +--- a/boot/Kconfig ++++ b/boot/Kconfig +@@ -633,10 +633,6 @@ config TEXT_BASE + depends on HAVE_TEXT_BASE + default 0x0 if POSITION_INDEPENDENT + default 0x80800000 if ARCH_OMAP2PLUS || ARCH_K3 +- default 0x81700000 if MACH_SUNIV +- default 0x2a000000 if MACH_SUN9I +- default 0x4a000000 if SUNXI_MINIMUM_DRAM_MB >= 256 +- default 0x42e00000 if SUNXI_MINIMUM_DRAM_MB >= 64 + hex "Text Base" + help + The address in memory that U-Boot will be running from, initially. diff --git a/package/boot/uboot-d1/patches/0071-sunxi-Move-most-board-options-to-the-board-Kconfig.patch b/package/boot/uboot-d1/patches/0071-sunxi-Move-most-board-options-to-the-board-Kconfig.patch new file mode 100644 index 00000000000000..fdcd72568766cf --- /dev/null +++ b/package/boot/uboot-d1/patches/0071-sunxi-Move-most-board-options-to-the-board-Kconfig.patch @@ -0,0 +1,197 @@ +From 6a1b660a83b262237b6bebed26e44db923a86a6b Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 18:09:19 +0000 +Subject: [PATCH 71/90] sunxi: Move most board options to the board Kconfig + +This excludes options that are inherently ARM-specific or are specific +to legacy non-DM drivers. + +Some help text is cleaned up along the way. + +Signed-off-by: Samuel Holland +Signed-off-by: Zoltan HERPAI +--- + arch/arm/mach-sunxi/Kconfig | 71 ------------------------------------ + board/sunxi/Kconfig | 72 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 72 insertions(+), 71 deletions(-) + +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -548,16 +548,6 @@ config DRAM_ODT_CORRECTION + then the correction is negative. Usually the value for this is 0. + endif + +-config UART0_PORT_F +- bool "UART0 on MicroSD breakout board" +- ---help--- +- Repurpose the SD card slot for getting access to the UART0 serial +- console. Primarily useful only for low level u-boot debugging on +- tablets, where normal UART0 is difficult to access and requires +- device disassembly and/or soldering. As the SD card can't be used +- at the same time, the system can be only booted in the FEL mode. +- Only enable this if you really know what you are doing. +- + config OLD_SUNXI_KERNEL_COMPAT + bool "Enable workarounds for booting old kernels" + ---help--- +@@ -571,20 +561,6 @@ config MACPWR + Set the pin used to power the MAC. This takes a string in the format + understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + +-config MMC1_PINS_PH +- bool "Pins for mmc1 are on Port H" +- depends on MACH_SUN4I || MACH_SUN7I || MACH_SUN8I_R40 +- ---help--- +- Select this option for boards where mmc1 uses the Port H pinmux. +- +-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. +- + config I2C0_ENABLE + bool "Enable I2C/TWI controller 0" + default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I_R40 +@@ -612,16 +588,6 @@ config R_I2C_ENABLE + Set this to y to enable the I2C controller which is part of the PRCM. + endif + +-config AXP_DISABLE_BOOT_ON_POWERON +- bool "Disable device boot on power plug-in" +- depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER +- default n +- ---help--- +- Say Y here to prevent the device from booting up because of a plug-in +- event. When set, the device will boot into the SPL briefly to +- determine why it was powered on, and if it was determined because of +- a plug-in event instead of a button press event it will shut back off. +- + config VIDEO_SUNXI + bool "Enable graphical uboot console on HDMI, LCD or VGA" + depends on !MACH_SUN8I_A83T +@@ -850,41 +816,4 @@ config SPL_SPI_SUNXI + sunxi SPI Flash. It uses the same method as the boot ROM, so does + not need any extra configuration. + +-config PINE64_DT_SELECTION +- bool "Enable Pine64 device tree selection code" +- depends on MACH_SUN50I +- help +- The original Pine A64 and Pine A64+ are similar but different +- boards and can be differed by the DRAM size. Pine A64 has +- 512MiB DRAM, and Pine A64+ has 1GiB or 2GiB. By selecting this +- option, the device tree selection code specific to Pine64 which +- utilizes the DRAM size will be enabled. +- +-config PINEPHONE_DT_SELECTION +- bool "Enable PinePhone device tree selection code" +- depends on MACH_SUN50I +- help +- Enable this option to automatically select the device tree for the +- correct PinePhone hardware revision during boot. +- +-config BLUETOOTH_DT_DEVICE_FIXUP +- string "Fixup the Bluetooth controller address" +- default "" +- help +- This option specifies the DT compatible name of the Bluetooth +- controller for which to set the "local-bd-address" property. +- Set this option if your device ships with the Bluetooth controller +- default address. +- The used address is "bdaddr" if set, and "ethaddr" with the LSB +- flipped elsewise. +- + endif +- +-config CHIP_DIP_SCAN +- bool "Enable DIPs detection for CHIP board" +- select SUPPORT_EXTENSION_SCAN +- select W1 +- select W1_GPIO +- select W1_EEPROM +- select W1_EEPROM_DS24XXX +- select CMD_EXTENSION +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -171,6 +171,78 @@ config SPL_IMAGE_TYPE + default "sunxi_egon" if SPL_IMAGE_TYPE_SUNXI_EGON + default "sunxi_toc0" if SPL_IMAGE_TYPE_SUNXI_TOC0 + ++config MMC_SUNXI_SLOT_EXTRA ++ int "MMC extra slot number" ++ default -1 ++ help ++ sunxi builds always enable mmc0. Some boards also have a ++ second SD card slot or eMMC on mmc1 - mmc3. Setting this to 1, ++ 2 or 3 will enable support for this. ++ ++config MMC1_PINS_PH ++ bool "MMC1 pins are on Port H" ++ depends on MACH_SUN4I || MACH_SUN7I || MACH_SUN8I_R40 ++ help ++ Select this option on boards where mmc1 uses the Port H pinmux. ++ ++config UART0_PORT_F ++ bool "UART0 pins are on Port F (MicroSD breakout board)" ++ help ++ Repurpose the SD card slot for getting access to the UART0 ++ serial console. Primarily useful only for low level u-boot ++ debugging on tablets, where normal UART0 is difficult to ++ access and requires device disassembly and/or soldering. As ++ the SD card can't be used at the same time, the system can be ++ only booted in FEL mode. Only enable this if you really know ++ what you are doing. ++ ++config AXP_DISABLE_BOOT_ON_POWERON ++ bool "Disable device boot on power plug-in" ++ depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER ++ help ++ Say Y here to prevent the device from booting up because of a ++ plug-in event. When set, the device will boot into the SPL ++ briefly to determine why it was powered on, and if the board ++ was powered on because of a plug-in event instead of a button ++ press event, it will shut back off. ++ ++config CHIP_DIP_SCAN ++ bool "Enable DIPs detection for CHIP board" ++ select SUPPORT_EXTENSION_SCAN ++ select W1 ++ select W1_GPIO ++ select W1_EEPROM ++ select W1_EEPROM_DS24XXX ++ select CMD_EXTENSION ++ ++config PINE64_DT_SELECTION ++ bool "Enable Pine64 device tree selection code" ++ depends on MACH_SUN50I ++ help ++ The original Pine A64 and Pine A64+ are similar but different ++ boards and can be differed by the DRAM size. Pine A64 has ++ 512MiB DRAM, and Pine A64+ has 1GiB or 2GiB. By selecting this ++ option, the device tree selection code specific to Pine64 which ++ utilizes the DRAM size will be enabled. ++ ++config PINEPHONE_DT_SELECTION ++ bool "Enable PinePhone device tree selection code" ++ depends on MACH_SUN50I ++ help ++ Enable this option to automatically select the device tree for the ++ correct PinePhone hardware revision during boot. ++ ++config BLUETOOTH_DT_DEVICE_FIXUP ++ string "Fixup the Bluetooth controller address" ++ default "" ++ help ++ This option specifies the DT compatible name of the Bluetooth ++ controller for which to set the "local-bd-address" property. ++ Set this option if your device ships with the Bluetooth controller ++ default address. ++ The used address is "bdaddr" if set, and "ethaddr" with the LSB ++ flipped elsewise. ++ + endmenu + + endif diff --git a/package/boot/uboot-d1/patches/0072-env-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch b/package/boot/uboot-d1/patches/0072-env-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch new file mode 100644 index 00000000000000..3fcfc205953e2c --- /dev/null +++ b/package/boot/uboot-d1/patches/0072-env-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch @@ -0,0 +1,69 @@ +From 27834df51087a005b0330f094492b984cc225f6a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 5 Aug 2022 23:28:54 -0500 +Subject: [PATCH 72/90] env: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI + +This ensures the same environment layout will be used across all sunxi +boards, regardless of CPU architecture. + +Signed-off-by: Samuel Holland +--- + env/Kconfig | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/env/Kconfig ++++ b/env/Kconfig +@@ -92,7 +92,7 @@ config ENV_IS_IN_FAT + bool "Environment is in a FAT filesystem" + depends on !CHAIN_OF_TRUST + default y if ARCH_BCM283X +- default y if ARCH_SUNXI && MMC ++ default y if BOARD_SUNXI && MMC + default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS + select FS_FAT + select FAT_WRITE +@@ -338,7 +338,7 @@ config ENV_IS_IN_SPI_FLASH + default y if NORTHBRIDGE_INTEL_IVYBRIDGE + default y if INTEL_QUARK + default y if INTEL_QUEENSBAY +- default y if ARCH_SUNXI ++ default y if BOARD_SUNXI + help + Define this if you have a SPI Flash memory device which you + want to use for the environment. +@@ -461,7 +461,7 @@ config ENV_FAT_DEVICE_AND_PART + depends on ENV_IS_IN_FAT + default "0:1" if TI_COMMON_CMD_OPTIONS + default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL +- default ":auto" if ARCH_SUNXI ++ default ":auto" if BOARD_SUNXI + default "0" if ARCH_AT91 + help + Define this to a string to specify the partition of the device. It can +@@ -555,7 +555,7 @@ config ENV_OFFSET + ENV_IS_IN_SPI_FLASH + default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC + default 0x140000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH +- default 0xF0000 if ARCH_SUNXI ++ default 0xF0000 if BOARD_SUNXI + default 0xE0000 if ARCH_ZYNQ + default 0x1E00000 if ARCH_ZYNQMP + default 0x7F40000 if ARCH_VERSAL || ARCH_VERSAL_NET +@@ -580,7 +580,7 @@ config ENV_SIZE + hex "Environment Size" + default 0x40000 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP + default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91 +- default 0x10000 if ARCH_SUNXI ++ default 0x10000 if BOARD_SUNXI + default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC + default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH + default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET +@@ -596,7 +596,7 @@ config ENV_SECT_SIZE + default 0x40000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET + default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91 + default 0x20000 if MICROBLAZE && ENV_IS_IN_SPI_FLASH +- default 0x10000 if ARCH_SUNXI && ENV_IS_IN_SPI_FLASH ++ default 0x10000 if BOARD_SUNXI && ENV_IS_IN_SPI_FLASH + help + Size of the sector containing the environment. + diff --git a/package/boot/uboot-d1/patches/0073-drivers-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch b/package/boot/uboot-d1/patches/0073-drivers-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch new file mode 100644 index 00000000000000..4e2386304037da --- /dev/null +++ b/package/boot/uboot-d1/patches/0073-drivers-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch @@ -0,0 +1,264 @@ +From 666d3c2bc058268a976397ec3e258f532edcfeb2 Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 18:12:11 +0000 +Subject: [PATCH 73/90] drivers: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI + +This provides a unified configuration across all sunxi boards, +regardless of CPU architecture. + +Signed-off-by: Samuel Holland +Signed-off-by: Zoltan HERPAI +--- + drivers/clk/sunxi/Kconfig | 2 +- + drivers/fastboot/Kconfig | 13 ++++++------- + drivers/gpio/Kconfig | 2 +- + drivers/mmc/Kconfig | 2 +- + drivers/net/phy/Kconfig | 4 ++-- + drivers/phy/allwinner/Kconfig | 2 +- + drivers/pinctrl/sunxi/Kconfig | 2 +- + drivers/reset/Kconfig | 2 +- + drivers/spi/Kconfig | 2 +- + drivers/usb/Kconfig | 2 +- + drivers/usb/gadget/Kconfig | 8 ++++---- + drivers/usb/musb-new/Kconfig | 2 +- + drivers/video/Kconfig | 2 +- + drivers/watchdog/Kconfig | 4 ++-- + 14 files changed, 24 insertions(+), 25 deletions(-) + +--- a/drivers/clk/sunxi/Kconfig ++++ b/drivers/clk/sunxi/Kconfig +@@ -1,6 +1,6 @@ + config CLK_SUNXI + bool "Clock support for Allwinner SoCs" +- depends on CLK && ARCH_SUNXI ++ depends on CLK && BOARD_SUNXI + select DM_RESET + select SPL_DM_RESET if SPL_CLK + default y +--- a/drivers/fastboot/Kconfig ++++ b/drivers/fastboot/Kconfig +@@ -8,7 +8,7 @@ config FASTBOOT + config USB_FUNCTION_FASTBOOT + bool "Enable USB fastboot gadget" + depends on USB_GADGET +- default y if ARCH_SUNXI && USB_MUSB_GADGET ++ default y if BOARD_SUNXI && USB_MUSB_GADGET + select FASTBOOT + select USB_GADGET_DOWNLOAD + help +@@ -32,10 +32,9 @@ if FASTBOOT + + config FASTBOOT_BUF_ADDR + hex "Define FASTBOOT buffer address" ++ default SYS_LOAD_ADDR if BOARD_SUNXI + default 0x82000000 if MX6SX || MX6SL || MX6UL || MX6SLL + default 0x81000000 if ARCH_OMAP2PLUS +- default 0x42000000 if ARCH_SUNXI && !MACH_SUN9I +- default 0x22000000 if ARCH_SUNXI && MACH_SUN9I + default 0x60800800 if ROCKCHIP_RK3036 || ROCKCHIP_RK3188 || \ + ROCKCHIP_RK322X + default 0x800800 if ROCKCHIP_RK3288 || ROCKCHIP_RK3329 || \ +@@ -52,7 +51,7 @@ config FASTBOOT_BUF_SIZE + hex "Define FASTBOOT buffer size" + default 0x8000000 if ARCH_ROCKCHIP + default 0x6000000 if ARCH_ZYNQMP +- default 0x2000000 if ARCH_SUNXI ++ default 0x2000000 if BOARD_SUNXI + default 0x8192 if SANDBOX + default 0x7000000 + help +@@ -71,7 +70,7 @@ config FASTBOOT_USB_DEV + + config FASTBOOT_FLASH + bool "Enable FASTBOOT FLASH command" +- default y if ARCH_SUNXI || ARCH_ROCKCHIP ++ default y if BOARD_SUNXI || ARCH_ROCKCHIP + depends on MMC || (MTD_RAW_NAND && CMD_MTDPARTS) + select IMAGE_SPARSE + help +@@ -105,8 +104,8 @@ config FASTBOOT_FLASH_MMC_DEV + int "Define FASTBOOT MMC FLASH default device" + depends on FASTBOOT_FLASH_MMC + default 0 if ARCH_ROCKCHIP +- default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 +- default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 ++ default 0 if BOARD_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 ++ default 1 if BOARD_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 + help + The fastboot "flash" command requires additional information + regarding the non-volatile storage device. Define this to +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -370,7 +370,7 @@ config SANDBOX_GPIO_COUNT + + config SUNXI_GPIO + bool "Allwinner GPIO driver" +- depends on ARCH_SUNXI ++ depends on BOARD_SUNXI + select SPL_STRTO if SPL + help + Support the GPIO device in Allwinner SoCs. +--- a/drivers/mmc/Kconfig ++++ b/drivers/mmc/Kconfig +@@ -756,7 +756,7 @@ config ZYNQ_HISPD_BROKEN + + config MMC_SUNXI + bool "Allwinner sunxi SD/MMC Host Controller support" +- depends on ARCH_SUNXI ++ depends on BOARD_SUNXI + default y + help + This selects support for the SD/MMC Host Controller on +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -19,14 +19,14 @@ if PHYLIB + + config PHY_ADDR_ENABLE + bool "Limit phy address" +- default y if ARCH_SUNXI ++ default y if BOARD_SUNXI + help + Select this if you want to control which phy address is used + + if PHY_ADDR_ENABLE + config PHY_ADDR + int "PHY address" +- default 1 if ARCH_SUNXI ++ default 1 if BOARD_SUNXI + default 0 + help + The address of PHY on MII bus. Usually in range of 0 to 31. +--- a/drivers/phy/allwinner/Kconfig ++++ b/drivers/phy/allwinner/Kconfig +@@ -3,7 +3,7 @@ + # + config PHY_SUN4I_USB + bool "Allwinner Sun4I USB PHY driver" +- depends on ARCH_SUNXI && !MACH_SUN9I ++ depends on depends on BOARD_SUNXI + default y + select DM_REGULATOR + select PHY +--- a/drivers/pinctrl/sunxi/Kconfig ++++ b/drivers/pinctrl/sunxi/Kconfig +@@ -1,6 +1,6 @@ + # SPDX-License-Identifier: GPL-2.0 + +-if ARCH_SUNXI ++if BOARD_SUNXI + + config PINCTRL_SUNXI + select PINCTRL_FULL +--- a/drivers/reset/Kconfig ++++ b/drivers/reset/Kconfig +@@ -137,7 +137,7 @@ config RESET_MTMIPS + + config RESET_SUNXI + bool "RESET support for Allwinner SoCs" +- depends on DM_RESET && ARCH_SUNXI ++ depends on DM_RESET && BOARD_SUNXI + default y + help + This enables support for common reset driver for +--- a/drivers/spi/Kconfig ++++ b/drivers/spi/Kconfig +@@ -453,7 +453,7 @@ config SOFT_SPI + + config SPI_SUNXI + bool "Allwinner SoC SPI controllers" +- default ARCH_SUNXI ++ default BOARD_SUNXI + help + Enable the Allwinner SoC SPi controller driver. + +--- a/drivers/usb/Kconfig ++++ b/drivers/usb/Kconfig +@@ -116,7 +116,7 @@ config USB_KEYBOARD_FN_KEYS + + choice + prompt "USB keyboard polling" +- default SYS_USB_EVENT_POLL_VIA_INT_QUEUE if ARCH_SUNXI ++ default SYS_USB_EVENT_POLL_VIA_INT_QUEUE if BOARD_SUNXI + default SYS_USB_EVENT_POLL + ---help--- + Enable a polling mechanism for USB keyboard. +--- a/drivers/usb/gadget/Kconfig ++++ b/drivers/usb/gadget/Kconfig +@@ -40,7 +40,7 @@ if USB_GADGET + + config USB_GADGET_MANUFACTURER + string "Vendor name of the USB device" +- default "Allwinner Technology" if ARCH_SUNXI ++ default "Allwinner Technology" if BOARD_SUNXI + default "Rockchip" if ARCH_ROCKCHIP + default "U-Boot" + help +@@ -49,7 +49,7 @@ config USB_GADGET_MANUFACTURER + + config USB_GADGET_VENDOR_NUM + hex "Vendor ID of the USB device" +- default 0x1f3a if ARCH_SUNXI ++ default 0x1f3a if BOARD_SUNXI + default 0x2207 if ARCH_ROCKCHIP + default 0x0 + help +@@ -59,7 +59,7 @@ config USB_GADGET_VENDOR_NUM + + config USB_GADGET_PRODUCT_NUM + hex "Product ID of the USB device" +- default 0x1010 if ARCH_SUNXI ++ default 0x1010 if BOARD_SUNXI + default 0x310a if ROCKCHIP_RK3036 + default 0x300a if ROCKCHIP_RK3066 + default 0x310c if ROCKCHIP_RK3128 +@@ -202,7 +202,7 @@ endif # USB_GADGET_DOWNLOAD + config USB_ETHER + bool "USB Ethernet Gadget" + depends on NET +- default y if ARCH_SUNXI && USB_MUSB_GADGET ++ default y if BOARD_SUNXI && USB_MUSB_GADGET + help + Creates an Ethernet network device through a USB peripheral + controller. This will create a network interface on both the device +--- a/drivers/usb/musb-new/Kconfig ++++ b/drivers/usb/musb-new/Kconfig +@@ -67,7 +67,7 @@ config USB_MUSB_PIC32 + + config USB_MUSB_SUNXI + bool "Enable sunxi OTG / DRC USB controller" +- depends on ARCH_SUNXI ++ depends on BOARD_SUNXI + select USB_MUSB_PIO_ONLY + default y + ---help--- +--- a/drivers/video/Kconfig ++++ b/drivers/video/Kconfig +@@ -183,7 +183,7 @@ config CONSOLE_TRUETYPE_MAX_METRICS + + config SYS_WHITE_ON_BLACK + bool "Display console as white on a black background" +- default y if ARCH_AT91 || ARCH_EXYNOS || ARCH_ROCKCHIP || ARCH_TEGRA || X86 || ARCH_SUNXI ++ default y if ARCH_AT91 || ARCH_EXYNOS || ARCH_ROCKCHIP || ARCH_TEGRA || X86 || BOARD_SUNXI + help + Normally the display is black on a white background, Enable this + option to invert this, i.e. white on a black background. This can be +--- a/drivers/watchdog/Kconfig ++++ b/drivers/watchdog/Kconfig +@@ -29,7 +29,7 @@ config WATCHDOG_TIMEOUT_MSECS + default 128000 if ARCH_MX31 || ARCH_MX5 || ARCH_MX6 + default 128000 if ARCH_MX7 || ARCH_VF610 + default 30000 if ARCH_SOCFPGA +- default 16000 if ARCH_SUNXI ++ default 16000 if BOARD_SUNXI + default 60000 + help + Watchdog timeout in msec +@@ -321,7 +321,7 @@ config WDT_STM32MP + + config WDT_SUNXI + bool "Allwinner sunxi watchdog timer support" +- depends on WDT && ARCH_SUNXI ++ depends on WDT && BOARD_SUNXI + default y + help + Enable support for the watchdog timer in Allwinner sunxi SoCs. diff --git a/package/boot/uboot-d1/patches/0074-disk-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch b/package/boot/uboot-d1/patches/0074-disk-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch new file mode 100644 index 00000000000000..68a3a684e02690 --- /dev/null +++ b/package/boot/uboot-d1/patches/0074-disk-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch @@ -0,0 +1,42 @@ +From 98fb93ceb936b375d7f8f2908f0703a93e27fbc4 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:05:52 -0500 +Subject: [PATCH 74/90] disk: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI + +This provides a unified configuration across all sunxi boards, +regardless of CPU architecture. + +Signed-off-by: Samuel Holland +--- + disk/Kconfig | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/disk/Kconfig ++++ b/disk/Kconfig +@@ -61,7 +61,7 @@ config SPL_DOS_PARTITION + bool "Enable MS Dos partition table for SPL" + depends on SPL + default n if ARCH_MVEBU +- default n if ARCH_SUNXI ++ default n if BOARD_SUNXI + default y if DOS_PARTITION + select SPL_PARTITIONS + +@@ -104,7 +104,7 @@ config EFI_PARTITION + config EFI_PARTITION_ENTRIES_NUMBERS + int "Number of the EFI partition entries" + depends on EFI_PARTITION +- default 56 if ARCH_SUNXI ++ default 56 if BOARD_SUNXI + default 128 + help + Specify the number of partition entries in the GPT. This is +@@ -132,7 +132,7 @@ config SPL_EFI_PARTITION + bool "Enable EFI GPT partition table for SPL" + depends on SPL + default n if ARCH_MVEBU +- default n if ARCH_SUNXI ++ default n if BOARD_SUNXI + default y if EFI_PARTITION + select SPL_PARTITIONS + diff --git a/package/boot/uboot-d1/patches/0075-spl-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch b/package/boot/uboot-d1/patches/0075-spl-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch new file mode 100644 index 00000000000000..81b6b45c7312af --- /dev/null +++ b/package/boot/uboot-d1/patches/0075-spl-sunxi-Replace-ARCH_SUNXI-with-BOARD_SUNXI.patch @@ -0,0 +1,81 @@ +From 7f06dca4df9302a22a8d27af887da50a67b7dd1d Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:09:38 -0500 +Subject: [PATCH 75/90] spl: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI + +This provides a unified configuration across all sunxi boards, +regardless of CPU architecture. + +Signed-off-by: Samuel Holland +--- + common/spl/Kconfig | 12 ++++++------ + scripts/Makefile.spl | 2 +- + 2 files changed, 7 insertions(+), 7 deletions(-) + +--- a/common/spl/Kconfig ++++ b/common/spl/Kconfig +@@ -111,7 +111,7 @@ config SPL_PAD_TO + config SPL_HAS_BSS_LINKER_SECTION + depends on SPL_FRAMEWORK + bool "Use a specific address for the BSS via the linker script" +- default y if ARCH_SUNXI || ARCH_MX6 || ARCH_OMAP2PLUS || MIPS || RISCV || ARCH_ZYNQMP ++ default y if ARCH_MX6 || ARCH_OMAP2PLUS || ARCH_ZYNQMP || BOARD_SUNXI || MIPS || RISCV + + config SPL_BSS_START_ADDR + hex "Link address for the BSS within the SPL binary" +@@ -335,7 +335,7 @@ config SPL_SYS_MALLOC_SIMPLE + config SPL_SHARES_INIT_SP_ADDR + bool "SPL and U-Boot use the same initial stack pointer location" + depends on (ARM || ARCH_JZ47XX || MICROBLAZE || RISCV) && SPL_FRAMEWORK +- default n if ARCH_SUNXI || ARCH_MX6 || ARCH_MX7 ++ default n if BOARD_SUNXI || ARCH_MX6 || ARCH_MX7 + default y + help + In many cases, we can use the same initial stack pointer address for +@@ -453,7 +453,7 @@ config SPL_DISPLAY_PRINT + + config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR + bool "MMC raw mode: by sector" +- default y if ARCH_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER || \ ++ default y if BOARD_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER || \ + ARCH_MX6 || ARCH_MX7 || \ + ARCH_ROCKCHIP || ARCH_MVEBU || ARCH_SOCFPGA || \ + ARCH_AT91 || ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \ +@@ -466,7 +466,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SEC + config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR + hex "Address on the MMC to load U-Boot from" + depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR +- default 0x40 if ARCH_SUNXI ++ default 0x40 if BOARD_SUNXI + default 0x75 if ARCH_DAVINCI + default 0x8a if ARCH_MX6 || ARCH_MX7 + default 0x100 if ARCH_UNIPHIER +@@ -483,7 +483,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR + config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET + hex "U-Boot main hardware partition image offset" + depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR +- default 0x10 if ARCH_SUNXI ++ default 0x10 if BOARD_SUNXI + default 0x0 + help + On some platforms SPL location depends on hardware partition. The ROM +@@ -1308,7 +1308,7 @@ endif # SPL_SPI_FLASH_SUPPORT + + config SYS_SPI_U_BOOT_OFFS + hex "address of u-boot payload in SPI flash" +- default 0x8000 if ARCH_SUNXI ++ default 0x8000 if BOARD_SUNXI + default 0x0 + depends on SPL_SPI_LOAD || SPL_SPI_SUNXI + help +--- a/scripts/Makefile.spl ++++ b/scripts/Makefile.spl +@@ -264,7 +264,7 @@ endif + + INPUTS-$(CONFIG_TARGET_SOCFPGA_SOC64) += $(obj)/u-boot-spl-dtb.hex + +-ifdef CONFIG_ARCH_SUNXI ++ifdef CONFIG_BOARD_SUNXI + INPUTS-y += $(obj)/sunxi-spl.bin + + ifdef CONFIG_NAND_SUNXI diff --git a/package/boot/uboot-d1/patches/0076-riscv-cpu-Add-cache-operations-for-T-HEAD-CPUs.patch b/package/boot/uboot-d1/patches/0076-riscv-cpu-Add-cache-operations-for-T-HEAD-CPUs.patch new file mode 100644 index 00000000000000..0555b6d9b409d8 --- /dev/null +++ b/package/boot/uboot-d1/patches/0076-riscv-cpu-Add-cache-operations-for-T-HEAD-CPUs.patch @@ -0,0 +1,153 @@ +From b6da98cd39612bb5660afbcad06e3a6bac43563e Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 11 Sep 2021 23:27:42 -0500 +Subject: [PATCH 76/90] riscv: cpu: Add cache operations for T-HEAD CPUs + +Signed-off-by: Samuel Holland +--- + arch/riscv/cpu/Makefile | 1 + + arch/riscv/cpu/thead/cache.c | 119 +++++++++++++++++++++++++++++++++++ + arch/riscv/lib/cache.c | 2 +- + 3 files changed, 121 insertions(+), 1 deletion(-) + create mode 100644 arch/riscv/cpu/thead/cache.c + +--- a/arch/riscv/cpu/Makefile ++++ b/arch/riscv/cpu/Makefile +@@ -5,3 +5,4 @@ + extra-y = start.o + + obj-y += cpu.o mtrap.o ++obj-y += thead/cache.o +--- /dev/null ++++ b/arch/riscv/cpu/thead/cache.c +@@ -0,0 +1,119 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++#include ++#include ++ ++#define CSR_MHCR 0x7c1 ++#define CSR_MCOR 0x7c2 ++#define CSR_MHINT 0x7c5 ++ ++#define MHCR_IE BIT(0) /* icache enable */ ++#define MHCR_DE BIT(1) /* dcache enable */ ++#define MHCR_WA BIT(2) /* dcache write allocate */ ++#define MHCR_WB BIT(3) /* dcache write back */ ++#define MHCR_RS BIT(4) /* return stack enable */ ++#define MHCR_BPE BIT(5) /* branch prediction enable */ ++#define MHCR_BTB BIT(6) /* branch target prediction enable */ ++#define MHCR_WBR BIT(8) /* write burst enable */ ++#define MHCR_L0BTB BIT(12) ++ ++#define MCOR_CACHE_SEL_ICACHE (0x1 << 0) ++#define MCOR_CACHE_SEL_DCACHE (0x2 << 0) ++#define MCOR_CACHE_SEL_BOTH (0x3 << 0) ++#define MCOR_INV BIT(4) ++#define MCOR_CLR BIT(5) ++#define MCOR_BHT_INV BIT(16) ++#define MCOR_BTB_INV BIT(17) ++ ++#define MHINT_DPLD BIT(2) /* dcache prefetch enable */ ++#define MHINT_AMR_PAGE (0x0 << 3) ++#define MHINT_AMR_LIMIT_3 (0x1 << 3) ++#define MHINT_AMR_LIMIT_64 (0x2 << 3) ++#define MHINT_AMR_LIMIT_128 (0x3 << 3) ++#define MHINT_IPLD BIT(8) /* icache prefetch enable */ ++#define MHINT_IWPE BIT(9) /* icache prediction enable */ ++#define MHINT_DIS_PREFETCH_2 (0x0 << 13) ++#define MHINT_DIS_PREFETCH_4 (0x1 << 13) ++#define MHINT_DIS_PREFETCH_8 (0x2 << 13) ++#define MHINT_DIS_PREFETCH_16 (0x3 << 13) ++ ++#define sync_i() asm volatile (".long 0x01a0000b" ::: "memory") ++ ++void flush_dcache_all(void) ++{ ++ asm volatile (".long 0x0030000b" ::: "memory"); /* dcache.ciall */ ++ sync_i(); ++} ++ ++void flush_dcache_range(unsigned long start, unsigned long end) ++{ ++ register unsigned long i asm("a0") = start & -CONFIG_SYS_CACHELINE_SIZE; ++ ++ for (; i < end; i += CONFIG_SYS_CACHELINE_SIZE) ++ asm volatile (".long 0x02b5000b" ::: "memory"); /* dcache.cipa a0 */ ++ sync_i(); ++} ++ ++void invalidate_icache_range(unsigned long start, unsigned long end) ++{ ++ register unsigned long i asm("a0") = start & -CONFIG_SYS_CACHELINE_SIZE; ++ ++ for (; i < end; i += CONFIG_SYS_CACHELINE_SIZE) ++ asm volatile (".long 0x0385000b" ::: "memory"); /* icache.ipa a0 */ ++ sync_i(); ++} ++ ++void invalidate_dcache_range(unsigned long start, unsigned long end) ++{ ++ register unsigned long i asm("a0") = start & -CONFIG_SYS_CACHELINE_SIZE; ++ ++ for (; i < end; i += CONFIG_SYS_CACHELINE_SIZE) ++ asm volatile (".long 0x02a5000b" ::: "memory"); /* dcache.ipa a0 */ ++ sync_i(); ++} ++ ++#if 0 ++void icache_enable(void) ++{ ++ asm volatile (".long 0x0100000b" ::: "memory"); /* icache.iall */ ++ sync_i(); ++ csr_set(CSR_MHCR, MHCR_IE | MHCR_RS | MHCR_BPE | MHCR_BTB | MHCR_L0BTB); ++ csr_set(CSR_MHINT, MHINT_IPLD | MHINT_IWPE); ++} ++ ++void icache_disable(void) ++{ ++ csr_clear(CSR_MHCR, MHCR_IE); ++} ++ ++int icache_status(void) ++{ ++ return csr_read(CSR_MHCR) & MHCR_IE; ++} ++ ++void dcache_enable(void) ++{ ++ asm volatile (".long 0x0020000b" ::: "memory"); /* dcache.iall */ ++ sync_i(); ++ csr_set(CSR_MHCR, MHCR_DE | MHCR_WA | MHCR_WB | MHCR_WBR); ++ csr_set(CSR_MHINT, MHINT_DPLD | MHINT_AMR_LIMIT_3); ++} ++ ++void dcache_disable(void) ++{ ++ asm volatile (".long 0x0010000b" ::: "memory"); /* dcache.call */ ++ sync_i(); ++ csr_clear(CSR_MHCR, MHCR_DE); ++} ++ ++int dcache_status(void) ++{ ++ return csr_read(CSR_MHCR) & MHCR_DE; ++} ++ ++void enable_caches(void) ++{ ++ icache_enable(); ++ dcache_enable(); ++} ++#endif +--- a/arch/riscv/lib/cache.c ++++ b/arch/riscv/lib/cache.c +@@ -20,7 +20,7 @@ __weak void flush_dcache_range(unsigned + { + } + +-void invalidate_icache_range(unsigned long start, unsigned long end) ++__weak void invalidate_icache_range(unsigned long start, unsigned long end) + { + /* + * RISC-V does not have an instruction for invalidating parts of the diff --git a/package/boot/uboot-d1/patches/0077-riscv-Sort-target-configs-alphabetically.patch b/package/boot/uboot-d1/patches/0077-riscv-Sort-target-configs-alphabetically.patch new file mode 100644 index 00000000000000..64577d8bd64424 --- /dev/null +++ b/package/boot/uboot-d1/patches/0077-riscv-Sort-target-configs-alphabetically.patch @@ -0,0 +1,43 @@ +From 35da34adec7b5b06ad81455a21c67a9c1152e2c9 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 7 Aug 2021 12:09:35 -0500 +Subject: [PATCH 77/90] riscv: Sort target configs alphabetically + +Signed-off-by: Samuel Holland +--- + arch/riscv/Kconfig | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -14,6 +14,9 @@ config TARGET_AX25_AE350 + config TARGET_MICROCHIP_ICICLE + bool "Support Microchip PolarFire-SoC Icicle Board" + ++config TARGET_OPENPITON_RISCV64 ++ bool "Support RISC-V cores on OpenPiton SoC" ++ + config TARGET_QEMU_VIRT + bool "Support QEMU Virt Board" + +@@ -28,9 +31,6 @@ config TARGET_SIPEED_MAIX + bool "Support Sipeed Maix Board" + select SYS_CACHE_SHIFT_6 + +-config TARGET_OPENPITON_RISCV64 +- bool "Support RISC-V cores on OpenPiton SoC" +- + endchoice + + config SYS_ICACHE_OFF +@@ -61,9 +61,9 @@ config SPL_SYS_DCACHE_OFF + source "board/AndesTech/ax25-ae350/Kconfig" + source "board/emulation/qemu-riscv/Kconfig" + source "board/microchip/mpfs_icicle/Kconfig" ++source "board/openpiton/riscv64/Kconfig" + source "board/sifive/unleashed/Kconfig" + source "board/sifive/unmatched/Kconfig" +-source "board/openpiton/riscv64/Kconfig" + source "board/sipeed/maix/Kconfig" + + # platform-specific options below diff --git a/package/boot/uboot-d1/patches/0078-riscv-Add-Allwinner-D1-devicetrees.patch b/package/boot/uboot-d1/patches/0078-riscv-Add-Allwinner-D1-devicetrees.patch new file mode 100644 index 00000000000000..09054d7455d934 --- /dev/null +++ b/package/boot/uboot-d1/patches/0078-riscv-Add-Allwinner-D1-devicetrees.patch @@ -0,0 +1,2138 @@ +From ce792f7abd4294ebba76f76d9d7aa90c7970de8e Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 4 Aug 2022 23:35:09 -0500 +Subject: [PATCH 78/90] riscv: Add Allwinner D1 devicetrees + +Signed-off-by: Samuel Holland +--- + arch/riscv/dts/Makefile | 9 + + .../riscv/dts/sun20i-d1-clockworkpi-v3.14.dts | 242 +++++ + .../dts/sun20i-d1-common-regulators.dtsi | 51 + + arch/riscv/dts/sun20i-d1-devterm-v3.14.dts | 37 + + .../dts/sun20i-d1-dongshan-nezha-stu.dts | 114 +++ + .../dts/sun20i-d1-lichee-rv-86-panel-480p.dts | 29 + + .../dts/sun20i-d1-lichee-rv-86-panel-720p.dts | 10 + + .../dts/sun20i-d1-lichee-rv-86-panel.dtsi | 92 ++ + arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts | 74 ++ + arch/riscv/dts/sun20i-d1-lichee-rv.dts | 84 ++ + arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts | 128 +++ + arch/riscv/dts/sun20i-d1-nezha.dts | 171 ++++ + arch/riscv/dts/sun20i-d1.dtsi | 900 ++++++++++++++++++ + arch/riscv/dts/sunxi-u-boot.dtsi | 68 ++ + include/dt-bindings/clock/sun20i-d1-r-ccu.h | 19 + + include/dt-bindings/reset/sun20i-d1-r-ccu.h | 16 + + 16 files changed, 2044 insertions(+) + create mode 100644 arch/riscv/dts/sun20i-d1-clockworkpi-v3.14.dts + create mode 100644 arch/riscv/dts/sun20i-d1-common-regulators.dtsi + create mode 100644 arch/riscv/dts/sun20i-d1-devterm-v3.14.dts + create mode 100644 arch/riscv/dts/sun20i-d1-dongshan-nezha-stu.dts + create mode 100644 arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-480p.dts + create mode 100644 arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-720p.dts + create mode 100644 arch/riscv/dts/sun20i-d1-lichee-rv-86-panel.dtsi + create mode 100644 arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts + create mode 100644 arch/riscv/dts/sun20i-d1-lichee-rv.dts + create mode 100644 arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts + create mode 100644 arch/riscv/dts/sun20i-d1-nezha.dts + create mode 100644 arch/riscv/dts/sun20i-d1.dtsi + create mode 100644 arch/riscv/dts/sunxi-u-boot.dtsi + create mode 100644 include/dt-bindings/clock/sun20i-d1-r-ccu.h + create mode 100644 include/dt-bindings/reset/sun20i-d1-r-ccu.h + +--- a/arch/riscv/dts/Makefile ++++ b/arch/riscv/dts/Makefile +@@ -7,6 +7,15 @@ dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) + + dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb + dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb + dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-clockworkpi-v3.14.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-devterm-v3.14.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-dongshan-nezha-stu.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-lichee-rv-86-panel-480p.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-lichee-rv-86-panel-720p.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-lichee-rv-dock.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-lichee-rv.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-mangopi-mq-pro.dtb ++dtb-$(CONFIG_TARGET_SUN20I_D1) += sun20i-d1-nezha.dtb + + include $(srctree)/scripts/Makefile.dts + +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-clockworkpi-v3.14.dts +@@ -0,0 +1,242 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include ++ ++#include "sun20i-d1.dtsi" ++#include "sun20i-d1-common-regulators.dtsi" ++ ++/ { ++ model = "ClockworkPi v3.14 (R-01)"; ++ compatible = "clockwork,r-01-clockworkpi-v3.14", "allwinner,sun20i-d1"; ++ ++ aliases { ++ ethernet0 = &ap6256; ++ mmc0 = &mmc0; ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ /* ++ * This regulator is PWM-controlled, but the PWM controller is not ++ * yet supported, so fix the regulator to its default voltage. ++ */ ++ reg_vdd_cpu: vdd-cpu { ++ compatible = "regulator-fixed"; ++ regulator-name = "vdd-cpu"; ++ regulator-min-microvolt = <1100000>; ++ regulator-max-microvolt = <1100000>; ++ vin-supply = <®_vcc>; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&pio 6 11 GPIO_ACTIVE_LOW>; /* PG11/GPIO3 */ ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_vdd_cpu>; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&i2c0 { ++ pinctrl-0 = <&i2c0_pb10_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ axp221: pmic@34 { ++ compatible = "x-powers,axp228", "x-powers,axp221"; ++ reg = <0x34>; ++ interrupt-parent = <&pio>; ++ interrupts = <4 9 IRQ_TYPE_LEVEL_LOW>; /* PE9/GPIO2 */ ++ interrupt-controller; ++ #interrupt-cells = <1>; ++ ++ ac_power_supply: ac-power { ++ compatible = "x-powers,axp221-ac-power-supply"; ++ }; ++ ++ axp_adc: adc { ++ compatible = "x-powers,axp221-adc"; ++ #io-channel-cells = <1>; ++ }; ++ ++ battery_power_supply: battery-power { ++ compatible = "x-powers,axp221-battery-power-supply"; ++ }; ++ ++ regulators { ++ x-powers,dcdc-freq = <3000>; ++ ++ reg_dcdc1: dcdc1 { ++ regulator-name = "sys-3v3"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_dcdc3: dcdc3 { ++ regulator-name = "sys-1v8"; ++ regulator-always-on; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ }; ++ ++ reg_aldo1: aldo1 { ++ regulator-name = "aud-3v3"; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_aldo2: aldo2 { ++ regulator-name = "disp-3v3"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_aldo3: aldo3 { ++ regulator-name = "vdd-wifi"; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ }; ++ ++ /* DLDO1 and ELDO1-3 are connected in parallel. */ ++ reg_dldo1: dldo1 { ++ regulator-name = "vbat-wifi-a"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ /* DLDO2-DLDO4 are connected in parallel. */ ++ reg_dldo2: dldo2 { ++ regulator-name = "vcc-3v3-ext-a"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_dldo3: dldo3 { ++ regulator-name = "vcc-3v3-ext-b"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_dldo4: dldo4 { ++ regulator-name = "vcc-3v3-ext-c"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_eldo1: eldo1 { ++ regulator-name = "vbat-wifi-b"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_eldo2: eldo2 { ++ regulator-name = "vbat-wifi-c"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ ++ reg_eldo3: eldo3 { ++ regulator-name = "vbat-wifi-d"; ++ regulator-always-on; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ }; ++ }; ++ ++ usb_power_supply: usb-power { ++ compatible = "x-powers,axp221-usb-power-supply"; ++ status = "disabled"; ++ }; ++ }; ++}; ++ ++&mmc0 { ++ broken-cd; ++ bus-width = <4>; ++ disable-wp; ++ vmmc-supply = <®_dcdc1>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&mmc1 { ++ bus-width = <4>; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ non-removable; ++ vmmc-supply = <®_dldo1>; ++ vqmmc-supply = <®_aldo3>; ++ pinctrl-0 = <&mmc1_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ ap6256: wifi@1 { ++ compatible = "brcm,bcm43456-fmac", "brcm,bcm4329-fmac"; ++ reg = <1>; ++ interrupt-parent = <&pio>; ++ interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10/GPIO4 */ ++ interrupt-names = "host-wake"; ++ }; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&pio { ++ vcc-pg-supply = <®_ldoa>; ++}; ++ ++&uart0 { ++ pinctrl-0 = <&uart0_pb8_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&uart1 { ++ uart-has-rtscts; ++ pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ bluetooth { ++ compatible = "brcm,bcm4345c5"; ++ interrupt-parent = <&pio>; ++ interrupts = <6 17 IRQ_TYPE_LEVEL_HIGH>; /* PG17/GPIO6 */ ++ device-wakeup-gpios = <&pio 6 16 GPIO_ACTIVE_HIGH>; /* PG16/GPIO7 */ ++ shutdown-gpios = <&pio 6 18 GPIO_ACTIVE_HIGH>; /* PG18/GPIO5 */ ++ max-speed = <1500000>; ++ vbat-supply = <®_dldo1>; ++ vddio-supply = <®_aldo3>; ++ }; ++}; ++ ++&usb_otg { ++ dr_mode = "peripheral"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb0_vbus_power-supply = <&ac_power_supply>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-common-regulators.dtsi +@@ -0,0 +1,51 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2021-2022 Samuel Holland ++ ++/ { ++ reg_vcc: vcc { ++ compatible = "regulator-fixed"; ++ regulator-name = "vcc"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ }; ++ ++ reg_vcc_3v3: vcc-3v3 { ++ compatible = "regulator-fixed"; ++ regulator-name = "vcc-3v3"; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ vin-supply = <®_vcc>; ++ }; ++}; ++ ++&lradc { ++ vref-supply = <®_aldo>; ++}; ++ ++&pio { ++ vcc-pb-supply = <®_vcc_3v3>; ++ vcc-pc-supply = <®_vcc_3v3>; ++ vcc-pd-supply = <®_vcc_3v3>; ++ vcc-pe-supply = <®_vcc_3v3>; ++ vcc-pf-supply = <®_vcc_3v3>; ++ vcc-pg-supply = <®_vcc_3v3>; ++}; ++ ++®_aldo { ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ vdd33-supply = <®_vcc_3v3>; ++}; ++ ++®_hpldo { ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ hpldoin-supply = <®_vcc_3v3>; ++}; ++ ++®_ldoa { ++ regulator-always-on; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ ldo-in-supply = <®_vcc_3v3>; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-devterm-v3.14.dts +@@ -0,0 +1,37 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include "sun20i-d1-clockworkpi-v3.14.dts" ++ ++/ { ++ model = "Clockwork DevTerm (R-01)"; ++ compatible = "clockwork,r-01-devterm-v3.14", ++ "clockwork,r-01-clockworkpi-v3.14", ++ "allwinner,sun20i-d1"; ++ ++ fan { ++ compatible = "gpio-fan"; ++ gpios = <&pio 3 10 GPIO_ACTIVE_HIGH>; /* PD10/GPIO41 */ ++ gpio-fan,speed-map = <0 0>, ++ <6000 1>; ++ #cooling-cells = <2>; ++ }; ++ ++ i2c-gpio-0 { ++ compatible = "i2c-gpio"; ++ sda-gpios = <&pio 3 14 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PD14/GPIO44 */ ++ scl-gpios = <&pio 3 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PD15/GPIO45 */ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ adc@54 { ++ compatible = "ti,adc101c"; ++ reg = <0x54>; ++ interrupt-parent = <&pio>; ++ interrupts = <4 12 IRQ_TYPE_LEVEL_LOW>; /* PE12/GPIO35 */ ++ vref-supply = <®_dldo2>; ++ }; ++ }; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-dongshan-nezha-stu.dts +@@ -0,0 +1,114 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include ++#include ++ ++#include "sun20i-d1.dtsi" ++#include "sun20i-d1-common-regulators.dtsi" ++ ++/ { ++ model = "Dongshan Nezha STU"; ++ compatible = "100ask,dongshan-nezha-stu", "allwinner,sun20i-d1"; ++ ++ aliases { ++ ethernet0 = &emac; ++ mmc0 = &mmc0; ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led-0 { ++ color = ; ++ function = LED_FUNCTION_STATUS; ++ gpios = <&pio 2 1 GPIO_ACTIVE_HIGH>; /* PC1 */ ++ }; ++ }; ++ ++ reg_usbvbus: usbvbus { ++ compatible = "regulator-fixed"; ++ regulator-name = "usbvbus"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ gpio = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ ++ enable-active-high; ++ vin-supply = <®_vcc>; ++ }; ++ ++ /* ++ * This regulator is PWM-controlled, but the PWM controller is not ++ * yet supported, so fix the regulator to its default voltage. ++ */ ++ reg_vdd_cpu: vdd-cpu { ++ compatible = "regulator-fixed"; ++ regulator-name = "vdd-cpu"; ++ regulator-min-microvolt = <1100000>; ++ regulator-max-microvolt = <1100000>; ++ vin-supply = <®_vcc>; ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_vdd_cpu>; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&emac { ++ pinctrl-0 = <&rgmii_pe_pins>; ++ pinctrl-names = "default"; ++ phy-handle = <&ext_rgmii_phy>; ++ phy-mode = "rgmii-id"; ++ phy-supply = <®_vcc_3v3>; ++ status = "okay"; ++}; ++ ++&mdio { ++ ext_rgmii_phy: ethernet-phy@1 { ++ compatible = "ethernet-phy-ieee802.3-c22"; ++ reg = <1>; ++ }; ++}; ++ ++&mmc0 { ++ broken-cd; ++ bus-width = <4>; ++ disable-wp; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-0 = <&uart0_pb8_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb0_id_det-gpios = <&pio 3 21 GPIO_ACTIVE_HIGH>; /* PD21 */ ++ usb0_vbus_det-gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ ++ usb0_vbus-supply = <®_usbvbus>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-480p.dts +@@ -0,0 +1,29 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++#include "sun20i-d1-lichee-rv-86-panel.dtsi" ++ ++/ { ++ model = "Sipeed Lichee RV 86 Panel (480p)"; ++ compatible = "sipeed,lichee-rv-86-panel-480p", "sipeed,lichee-rv", ++ "allwinner,sun20i-d1"; ++}; ++ ++&i2c2 { ++ pinctrl-0 = <&i2c2_pb0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ touchscreen@48 { ++ compatible = "focaltech,ft6236"; ++ reg = <0x48>; ++ interrupt-parent = <&pio>; ++ interrupts = <6 14 IRQ_TYPE_LEVEL_LOW>; /* PG14 */ ++ iovcc-supply = <®_vcc_3v3>; ++ reset-gpios = <&pio 6 15 GPIO_ACTIVE_LOW>; /* PG15 */ ++ touchscreen-size-x = <480>; ++ touchscreen-size-y = <480>; ++ vcc-supply = <®_vcc_3v3>; ++ wakeup-source; ++ }; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-720p.dts +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++#include "sun20i-d1-lichee-rv-86-panel.dtsi" ++ ++/ { ++ model = "Sipeed Lichee RV 86 Panel (720p)"; ++ compatible = "sipeed,lichee-rv-86-panel-720p", "sipeed,lichee-rv", ++ "allwinner,sun20i-d1"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel.dtsi +@@ -0,0 +1,92 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++#include "sun20i-d1-lichee-rv.dts" ++ ++/ { ++ aliases { ++ ethernet0 = &emac; ++ ethernet1 = &xr829; ++ }; ++ ++ /* PC1 is repurposed as BT_WAKE_AP */ ++ /delete-node/ leds; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ clocks = <&ccu CLK_FANOUT1>; ++ clock-names = "ext_clock"; ++ reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ ++ assigned-clocks = <&ccu CLK_FANOUT1>; ++ assigned-clock-rates = <32768>; ++ pinctrl-0 = <&clk_pg11_pin>; ++ pinctrl-names = "default"; ++ }; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&emac { ++ pinctrl-0 = <&rmii_pe_pins>; ++ pinctrl-names = "default"; ++ phy-handle = <&ext_rmii_phy>; ++ phy-mode = "rmii"; ++ phy-supply = <®_vcc_3v3>; ++ status = "okay"; ++}; ++ ++&mdio { ++ ext_rmii_phy: ethernet-phy@1 { ++ compatible = "ethernet-phy-ieee802.3-c22"; ++ reg = <1>; ++ reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* PE16 */ ++ }; ++}; ++ ++&mmc1 { ++ bus-width = <4>; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ non-removable; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc1_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ xr829: wifi@1 { ++ reg = <1>; ++ }; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&pio { ++ clk_pg11_pin: clk-pg11-pin { ++ pins = "PG11"; ++ function = "clk"; ++ }; ++}; ++ ++&uart1 { ++ uart-has-rtscts; ++ pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ /* XR829 bluetooth is connected here */ ++}; ++ ++&usb_otg { ++ status = "disabled"; ++}; ++ ++&usbphy { ++ /* PD20 and PD21 are repurposed for the LCD panel */ ++ /delete-property/ usb0_id_det-gpios; ++ /delete-property/ usb0_vbus_det-gpios; ++ usb1_vbus-supply = <®_vcc>; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts +@@ -0,0 +1,74 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Jisheng Zhang ++// Copyright (C) 2022 Samuel Holland ++ ++#include ++ ++#include "sun20i-d1-lichee-rv.dts" ++ ++/ { ++ model = "Sipeed Lichee RV Dock"; ++ compatible = "sipeed,lichee-rv-dock", "sipeed,lichee-rv", ++ "allwinner,sun20i-d1"; ++ ++ aliases { ++ ethernet1 = &rtl8723ds; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ ++ }; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&lradc { ++ status = "okay"; ++ ++ button-220 { ++ label = "OK"; ++ linux,code = ; ++ channel = <0>; ++ voltage = <220000>; ++ }; ++}; ++ ++&mmc1 { ++ bus-width = <4>; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ non-removable; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc1_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ rtl8723ds: wifi@1 { ++ reg = <1>; ++ }; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&uart1 { ++ uart-has-rtscts; ++ pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ bluetooth { ++ compatible = "realtek,rtl8723ds-bt"; ++ device-wake-gpios = <&pio 6 15 GPIO_ACTIVE_HIGH>; /* PG16 */ ++ enable-gpios = <&pio 6 18 GPIO_ACTIVE_HIGH>; /* PG18 */ ++ host-wake-gpios = <&pio 6 17 GPIO_ACTIVE_HIGH>; /* PG17 */ ++ }; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_vcc>; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv.dts +@@ -0,0 +1,84 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Jisheng Zhang ++// Copyright (C) 2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include ++#include ++ ++#include "sun20i-d1.dtsi" ++#include "sun20i-d1-common-regulators.dtsi" ++ ++/ { ++ model = "Sipeed Lichee RV"; ++ compatible = "sipeed,lichee-rv", "allwinner,sun20i-d1"; ++ ++ aliases { ++ mmc0 = &mmc0; ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led-0 { ++ color = ; ++ function = LED_FUNCTION_STATUS; ++ gpios = <&pio 2 1 GPIO_ACTIVE_HIGH>; /* PC1 */ ++ }; ++ }; ++ ++ reg_vdd_cpu: vdd-cpu { ++ compatible = "regulator-fixed"; ++ regulator-name = "vdd-cpu"; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <900000>; ++ vin-supply = <®_vcc>; ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_vdd_cpu>; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&mmc0 { ++ broken-cd; ++ bus-width = <4>; ++ disable-wp; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-0 = <&uart0_pb8_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb0_id_det-gpios = <&pio 3 21 GPIO_ACTIVE_HIGH>; /* PD21 */ ++ usb0_vbus_det-gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ ++ usb0_vbus-supply = <®_vcc>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts +@@ -0,0 +1,128 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include ++ ++#include "sun20i-d1.dtsi" ++#include "sun20i-d1-common-regulators.dtsi" ++ ++/ { ++ model = "MangoPi MQ Pro"; ++ compatible = "widora,mangopi-mq-pro", "allwinner,sun20i-d1"; ++ ++ aliases { ++ ethernet0 = &rtl8723ds; ++ mmc0 = &mmc0; ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ reg_avdd2v8: avdd2v8 { ++ compatible = "regulator-fixed"; ++ regulator-name = "avdd2v8"; ++ regulator-min-microvolt = <2800000>; ++ regulator-max-microvolt = <2800000>; ++ vin-supply = <®_vcc_3v3>; ++ }; ++ ++ reg_dvdd: dvdd { ++ compatible = "regulator-fixed"; ++ regulator-name = "dvdd"; ++ regulator-min-microvolt = <1200000>; ++ regulator-max-microvolt = <1200000>; ++ vin-supply = <®_vcc_3v3>; ++ }; ++ ++ reg_vdd_cpu: vdd-cpu { ++ compatible = "regulator-fixed"; ++ regulator-name = "vdd-cpu"; ++ regulator-min-microvolt = <1100000>; ++ regulator-max-microvolt = <1100000>; ++ vin-supply = <®_vcc>; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&pio 6 17 GPIO_ACTIVE_LOW>; /* PG17 */ ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_vdd_cpu>; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&mmc0 { ++ bus-width = <4>; ++ cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ ++ disable-wp; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&mmc1 { ++ bus-width = <4>; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ non-removable; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc1_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ rtl8723ds: wifi@1 { ++ reg = <1>; ++ interrupt-parent = <&pio>; ++ interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 */ ++ interrupt-names = "host-wake"; ++ }; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&pio { ++ vcc-pe-supply = <®_avdd2v8>; ++}; ++ ++&uart0 { ++ pinctrl-0 = <&uart0_pb8_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&uart1 { ++ uart-has-rtscts; ++ pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ bluetooth { ++ compatible = "realtek,rtl8723ds-bt"; ++ device-wake-gpios = <&pio 6 18 GPIO_ACTIVE_HIGH>; /* PG18 */ ++ enable-gpios = <&pio 6 15 GPIO_ACTIVE_HIGH>; /* PG15 */ ++ host-wake-gpios = <&pio 6 14 GPIO_ACTIVE_HIGH>; /* PG14 */ ++ }; ++}; ++ ++&usb_otg { ++ dr_mode = "peripheral"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb0_vbus-supply = <®_vcc>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1-nezha.dts +@@ -0,0 +1,171 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2021-2022 Samuel Holland ++ ++/dts-v1/; ++ ++#include ++#include ++ ++#include "sun20i-d1.dtsi" ++#include "sun20i-d1-common-regulators.dtsi" ++ ++/ { ++ model = "Allwinner D1 Nezha"; ++ compatible = "allwinner,d1-nezha", "allwinner,sun20i-d1"; ++ ++ aliases { ++ ethernet0 = &emac; ++ ethernet1 = &xr829; ++ mmc0 = &mmc0; ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ reg_usbvbus: usbvbus { ++ compatible = "regulator-fixed"; ++ regulator-name = "usbvbus"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ gpio = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ ++ enable-active-high; ++ vin-supply = <®_vcc>; ++ }; ++ ++ /* ++ * This regulator is PWM-controlled, but the PWM controller is not ++ * yet supported, so fix the regulator to its default voltage. ++ */ ++ reg_vdd_cpu: vdd-cpu { ++ compatible = "regulator-fixed"; ++ regulator-name = "vdd-cpu"; ++ regulator-min-microvolt = <1100000>; ++ regulator-max-microvolt = <1100000>; ++ vin-supply = <®_vcc>; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_vdd_cpu>; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&emac { ++ pinctrl-0 = <&rgmii_pe_pins>; ++ pinctrl-names = "default"; ++ phy-handle = <&ext_rgmii_phy>; ++ phy-mode = "rgmii-id"; ++ phy-supply = <®_vcc_3v3>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-0 = <&i2c2_pb0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ pcf8574a: gpio@38 { ++ compatible = "nxp,pcf8574a"; ++ reg = <0x38>; ++ interrupt-parent = <&pio>; ++ interrupts = <1 2 IRQ_TYPE_LEVEL_LOW>; /* PB2 */ ++ interrupt-controller; ++ gpio-controller; ++ #gpio-cells = <2>; ++ #interrupt-cells = <2>; ++ }; ++}; ++ ++&lradc { ++ status = "okay"; ++ ++ button-160 { ++ label = "OK"; ++ linux,code = ; ++ channel = <0>; ++ voltage = <160000>; ++ }; ++}; ++ ++&mdio { ++ ext_rgmii_phy: ethernet-phy@1 { ++ compatible = "ethernet-phy-ieee802.3-c22"; ++ reg = <1>; ++ }; ++}; ++ ++&mmc0 { ++ bus-width = <4>; ++ cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ ++ disable-wp; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&mmc1 { ++ bus-width = <4>; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ non-removable; ++ vmmc-supply = <®_vcc_3v3>; ++ vqmmc-supply = <®_vcc_3v3>; ++ pinctrl-0 = <&mmc1_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ xr829: wifi@1 { ++ reg = <1>; ++ }; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-0 = <&uart0_pb8_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&uart1 { ++ uart-has-rtscts; ++ pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ /* XR829 bluetooth is connected here */ ++}; ++ ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb0_id_det-gpios = <&pio 3 21 GPIO_ACTIVE_HIGH>; /* PD21 */ ++ usb0_vbus_det-gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ ++ usb0_vbus-supply = <®_usbvbus>; ++ usb1_vbus-supply = <®_vcc>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sun20i-d1.dtsi +@@ -0,0 +1,900 @@ ++// SPDX-License-Identifier: (GPL-2.0+ or MIT) ++// Copyright (C) 2021-2022 Samuel Holland ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/ { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ cpus { ++ timebase-frequency = <24000000>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ cpu0: cpu@0 { ++ compatible = "thead,c906", "riscv"; ++ device_type = "cpu"; ++ reg = <0>; ++ clocks = <&ccu CLK_RISCV>; ++ clock-frequency = <24000000>; ++ d-cache-block-size = <64>; ++ d-cache-sets = <256>; ++ d-cache-size = <32768>; ++ i-cache-block-size = <64>; ++ i-cache-sets = <128>; ++ i-cache-size = <32768>; ++ mmu-type = "riscv,sv39"; ++ riscv,isa = "rv64imafdc"; ++ #cooling-cells = <2>; ++ ++ cpu0_intc: interrupt-controller { ++ compatible = "riscv,cpu-intc"; ++ interrupt-controller; ++ #address-cells = <0>; ++ #interrupt-cells = <1>; ++ }; ++ }; ++ }; ++ ++ de: display-engine { ++ compatible = "allwinner,sun20i-d1-display-engine"; ++ allwinner,pipelines = <&mixer0>, <&mixer1>; ++ status = "disabled"; ++ }; ++ ++ osc24M: osc24M-clk { ++ compatible = "fixed-clock"; ++ clock-frequency = <24000000>; ++ clock-output-names = "osc24M"; ++ #clock-cells = <0>; ++ }; ++ ++ soc { ++ compatible = "simple-bus"; ++ ranges; ++ interrupt-parent = <&plic>; ++ dma-noncoherent; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ dsp_wdt: watchdog@1700400 { ++ compatible = "allwinner,sun20i-d1-wdt"; ++ reg = <0x1700400 0x20>; ++ interrupts = <138 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>, <&rtc CLK_OSC32K>; ++ clock-names = "hosc", "losc"; ++ status = "reserved"; ++ }; ++ ++ pio: pinctrl@2000000 { ++ compatible = "allwinner,sun20i-d1-pinctrl"; ++ reg = <0x2000000 0x800>; ++ interrupts = <85 IRQ_TYPE_LEVEL_HIGH>, ++ <87 IRQ_TYPE_LEVEL_HIGH>, ++ <89 IRQ_TYPE_LEVEL_HIGH>, ++ <91 IRQ_TYPE_LEVEL_HIGH>, ++ <93 IRQ_TYPE_LEVEL_HIGH>, ++ <95 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_APB0>, ++ <&osc24M>, ++ <&rtc CLK_OSC32K>; ++ clock-names = "apb", "hosc", "losc"; ++ gpio-controller; ++ interrupt-controller; ++ #gpio-cells = <3>; ++ #interrupt-cells = <3>; ++ ++ /omit-if-no-ref/ ++ i2c0_pb10_pins: i2c0-pb10-pins { ++ pins = "PB10", "PB11"; ++ function = "i2c0"; ++ }; ++ ++ /omit-if-no-ref/ ++ i2c2_pb0_pins: i2c2-pb0-pins { ++ pins = "PB0", "PB1"; ++ function = "i2c2"; ++ }; ++ ++ /omit-if-no-ref/ ++ lcd_rgb666_pins: lcd-rgb666-pins { ++ pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", ++ "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", ++ "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", ++ "PD18", "PD19", "PD20", "PD21"; ++ function = "lcd0"; ++ }; ++ ++ /omit-if-no-ref/ ++ mmc0_pins: mmc0-pins { ++ pins = "PF0", "PF1", "PF2", "PF3", "PF4", "PF5"; ++ function = "mmc0"; ++ }; ++ ++ /omit-if-no-ref/ ++ mmc1_pins: mmc1-pins { ++ pins = "PG0", "PG1", "PG2", "PG3", "PG4", "PG5"; ++ function = "mmc1"; ++ }; ++ ++ /omit-if-no-ref/ ++ mmc2_pins: mmc2-pins { ++ pins = "PC2", "PC3", "PC4", "PC5", "PC6", "PC7"; ++ function = "mmc2"; ++ }; ++ ++ /omit-if-no-ref/ ++ rgmii_pe_pins: rgmii-pe-pins { ++ pins = "PE0", "PE1", "PE2", "PE3", "PE4", ++ "PE5", "PE6", "PE7", "PE8", "PE9", ++ "PE11", "PE12", "PE13", "PE14", "PE15"; ++ function = "emac"; ++ }; ++ ++ /omit-if-no-ref/ ++ rmii_pe_pins: rmii-pe-pins { ++ pins = "PE0", "PE1", "PE2", "PE3", "PE4", ++ "PE5", "PE6", "PE7", "PE8", "PE9"; ++ function = "emac"; ++ }; ++ ++ /omit-if-no-ref/ ++ uart0_pb8_pins: uart0-pb8-pins { ++ pins = "PB8", "PB9"; ++ function = "uart0"; ++ }; ++ ++ /omit-if-no-ref/ ++ uart1_pg6_pins: uart1-pg6-pins { ++ pins = "PG6", "PG7"; ++ function = "uart1"; ++ }; ++ ++ /omit-if-no-ref/ ++ uart1_pg8_rts_cts_pins: uart1-pg8-rts-cts-pins { ++ pins = "PG8", "PG9"; ++ function = "uart1"; ++ }; ++ }; ++ ++ ccu: clock-controller@2001000 { ++ compatible = "allwinner,sun20i-d1-ccu"; ++ reg = <0x2001000 0x1000>; ++ clocks = <&osc24M>, ++ <&rtc CLK_OSC32K>, ++ <&rtc CLK_IOSC>; ++ clock-names = "hosc", "losc", "iosc"; ++ #clock-cells = <1>; ++ #reset-cells = <1>; ++ }; ++ ++ lradc: keys@2009800 { ++ compatible = "allwinner,sun20i-d1-lradc", ++ "allwinner,sun50i-r329-lradc"; ++ reg = <0x2009800 0x400>; ++ interrupts = <77 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_LRADC>; ++ resets = <&ccu RST_BUS_LRADC>; ++ status = "disabled"; ++ }; ++ ++ codec: audio-codec@2030000 { ++ compatible = "simple-mfd", "syscon"; ++ reg = <0x2030000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ regulators@2030348 { ++ compatible = "allwinner,sun20i-d1-analog-ldos"; ++ reg = <0x2030348 0x4>; ++ nvmem-cells = <&bg_trim>; ++ nvmem-cell-names = "bg_trim"; ++ ++ reg_aldo: aldo { ++ }; ++ ++ reg_hpldo: hpldo { ++ }; ++ }; ++ }; ++ ++ i2s0: i2s@2032000 { ++ compatible = "allwinner,sun20i-d1-i2s", ++ "allwinner,sun50i-r329-i2s"; ++ reg = <0x2032000 0x1000>; ++ interrupts = <42 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2S0>, ++ <&ccu CLK_I2S0>; ++ clock-names = "apb", "mod"; ++ resets = <&ccu RST_BUS_I2S0>; ++ dmas = <&dma 3>, <&dma 3>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #sound-dai-cells = <0>; ++ }; ++ ++ i2s1: i2s@2033000 { ++ compatible = "allwinner,sun20i-d1-i2s", ++ "allwinner,sun50i-r329-i2s"; ++ reg = <0x2033000 0x1000>; ++ interrupts = <43 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2S1>, ++ <&ccu CLK_I2S1>; ++ clock-names = "apb", "mod"; ++ resets = <&ccu RST_BUS_I2S1>; ++ dmas = <&dma 4>, <&dma 4>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #sound-dai-cells = <0>; ++ }; ++ ++ i2s2: i2s@2034000 { ++ compatible = "allwinner,sun20i-d1-i2s", ++ "allwinner,sun50i-r329-i2s"; ++ reg = <0x2034000 0x1000>; ++ interrupts = <44 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2S2>, ++ <&ccu CLK_I2S2>; ++ clock-names = "apb", "mod"; ++ resets = <&ccu RST_BUS_I2S2>; ++ dmas = <&dma 5>, <&dma 5>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #sound-dai-cells = <0>; ++ }; ++ ++ timer: timer@2050000 { ++ compatible = "allwinner,sun20i-d1-timer", ++ "allwinner,sun8i-a23-timer"; ++ reg = <0x2050000 0xa0>; ++ interrupts = <75 IRQ_TYPE_LEVEL_HIGH>, ++ <76 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>; ++ }; ++ ++ wdt: watchdog@20500a0 { ++ compatible = "allwinner,sun20i-d1-wdt-reset", ++ "allwinner,sun20i-d1-wdt"; ++ reg = <0x20500a0 0x20>; ++ interrupts = <79 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>, <&rtc CLK_OSC32K>; ++ clock-names = "hosc", "losc"; ++ status = "reserved"; ++ }; ++ ++ uart0: serial@2500000 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2500000 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <18 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART0>; ++ resets = <&ccu RST_BUS_UART0>; ++ dmas = <&dma 14>, <&dma 14>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ uart1: serial@2500400 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2500400 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <19 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART1>; ++ resets = <&ccu RST_BUS_UART1>; ++ dmas = <&dma 15>, <&dma 15>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ uart2: serial@2500800 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2500800 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <20 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART2>; ++ resets = <&ccu RST_BUS_UART2>; ++ dmas = <&dma 16>, <&dma 16>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ uart3: serial@2500c00 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2500c00 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <21 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART3>; ++ resets = <&ccu RST_BUS_UART3>; ++ dmas = <&dma 17>, <&dma 17>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ uart4: serial@2501000 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2501000 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <22 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART4>; ++ resets = <&ccu RST_BUS_UART4>; ++ dmas = <&dma 18>, <&dma 18>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ uart5: serial@2501400 { ++ compatible = "snps,dw-apb-uart"; ++ reg = <0x2501400 0x400>; ++ reg-io-width = <4>; ++ reg-shift = <2>; ++ interrupts = <23 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_UART5>; ++ resets = <&ccu RST_BUS_UART5>; ++ dmas = <&dma 19>, <&dma 19>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ ++ i2c0: i2c@2502000 { ++ compatible = "allwinner,sun20i-d1-i2c", ++ "allwinner,sun8i-v536-i2c", ++ "allwinner,sun6i-a31-i2c"; ++ reg = <0x2502000 0x400>; ++ interrupts = <25 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2C0>; ++ resets = <&ccu RST_BUS_I2C0>; ++ dmas = <&dma 43>, <&dma 43>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ i2c1: i2c@2502400 { ++ compatible = "allwinner,sun20i-d1-i2c", ++ "allwinner,sun8i-v536-i2c", ++ "allwinner,sun6i-a31-i2c"; ++ reg = <0x2502400 0x400>; ++ interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2C1>; ++ resets = <&ccu RST_BUS_I2C1>; ++ dmas = <&dma 44>, <&dma 44>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ i2c2: i2c@2502800 { ++ compatible = "allwinner,sun20i-d1-i2c", ++ "allwinner,sun8i-v536-i2c", ++ "allwinner,sun6i-a31-i2c"; ++ reg = <0x2502800 0x400>; ++ interrupts = <27 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2C2>; ++ resets = <&ccu RST_BUS_I2C2>; ++ dmas = <&dma 45>, <&dma 45>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ i2c3: i2c@2502c00 { ++ compatible = "allwinner,sun20i-d1-i2c", ++ "allwinner,sun8i-v536-i2c", ++ "allwinner,sun6i-a31-i2c"; ++ reg = <0x2502c00 0x400>; ++ interrupts = <28 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_I2C3>; ++ resets = <&ccu RST_BUS_I2C3>; ++ dmas = <&dma 46>, <&dma 46>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ syscon: syscon@3000000 { ++ compatible = "allwinner,sun20i-d1-system-control"; ++ reg = <0x3000000 0x1000>; ++ ranges; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ regulators@3000150 { ++ compatible = "allwinner,sun20i-d1-system-ldos"; ++ reg = <0x3000150 0x4>; ++ ++ reg_ldoa: ldoa { ++ }; ++ ++ reg_ldob: ldob { ++ }; ++ }; ++ }; ++ ++ dma: dma-controller@3002000 { ++ compatible = "allwinner,sun20i-d1-dma"; ++ reg = <0x3002000 0x1000>; ++ interrupts = <66 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_DMA>, <&ccu CLK_MBUS_DMA>; ++ clock-names = "bus", "mbus"; ++ resets = <&ccu RST_BUS_DMA>; ++ dma-channels = <16>; ++ dma-requests = <48>; ++ #dma-cells = <1>; ++ }; ++ ++ sid: efuse@3006000 { ++ compatible = "allwinner,sun20i-d1-sid"; ++ reg = <0x3006000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ ths_calib: ths-calib@14 { ++ reg = <0x14 0x4>; ++ }; ++ ++ bg_trim: bg-trim@28 { ++ reg = <0x28 0x4>; ++ bits = <16 8>; ++ }; ++ }; ++ ++ mbus: dram-controller@3102000 { ++ compatible = "allwinner,sun20i-d1-mbus"; ++ reg = <0x3102000 0x1000>, ++ <0x3103000 0x1000>; ++ reg-names = "mbus", "dram"; ++ interrupts = <59 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_MBUS>, ++ <&ccu CLK_DRAM>, ++ <&ccu CLK_BUS_DRAM>; ++ clock-names = "mbus", "dram", "bus"; ++ dma-ranges = <0 0x40000000 0x80000000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ #interconnect-cells = <1>; ++ }; ++ ++ mmc0: mmc@4020000 { ++ compatible = "allwinner,sun20i-d1-mmc"; ++ reg = <0x4020000 0x1000>; ++ interrupts = <56 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_MMC0>, <&ccu CLK_MMC0>; ++ clock-names = "ahb", "mmc"; ++ resets = <&ccu RST_BUS_MMC0>; ++ reset-names = "ahb"; ++ cap-sd-highspeed; ++ max-frequency = <150000000>; ++ no-mmc; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ mmc1: mmc@4021000 { ++ compatible = "allwinner,sun20i-d1-mmc"; ++ reg = <0x4021000 0x1000>; ++ interrupts = <57 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_MMC1>, <&ccu CLK_MMC1>; ++ clock-names = "ahb", "mmc"; ++ resets = <&ccu RST_BUS_MMC1>; ++ reset-names = "ahb"; ++ cap-sd-highspeed; ++ max-frequency = <150000000>; ++ no-mmc; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ mmc2: mmc@4022000 { ++ compatible = "allwinner,sun20i-d1-emmc", ++ "allwinner,sun50i-a100-emmc"; ++ reg = <0x4022000 0x1000>; ++ interrupts = <58 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_MMC2>, <&ccu CLK_MMC2>; ++ clock-names = "ahb", "mmc"; ++ resets = <&ccu RST_BUS_MMC2>; ++ reset-names = "ahb"; ++ cap-mmc-highspeed; ++ max-frequency = <150000000>; ++ mmc-ddr-1_8v; ++ mmc-ddr-3_3v; ++ no-sd; ++ no-sdio; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ usb_otg: usb@4100000 { ++ compatible = "allwinner,sun20i-d1-musb", ++ "allwinner,sun8i-a33-musb"; ++ reg = <0x4100000 0x400>; ++ interrupts = <45 IRQ_TYPE_LEVEL_HIGH>; ++ interrupt-names = "mc"; ++ clocks = <&ccu CLK_BUS_OTG>; ++ resets = <&ccu RST_BUS_OTG>; ++ extcon = <&usbphy 0>; ++ phys = <&usbphy 0>; ++ phy-names = "usb"; ++ status = "disabled"; ++ }; ++ ++ usbphy: phy@4100400 { ++ compatible = "allwinner,sun20i-d1-usb-phy"; ++ reg = <0x4100400 0x100>, ++ <0x4101800 0x100>, ++ <0x4200800 0x100>; ++ reg-names = "phy_ctrl", ++ "pmu0", ++ "pmu1"; ++ clocks = <&osc24M>, ++ <&osc24M>; ++ clock-names = "usb0_phy", ++ "usb1_phy"; ++ resets = <&ccu RST_USB_PHY0>, ++ <&ccu RST_USB_PHY1>; ++ reset-names = "usb0_reset", ++ "usb1_reset"; ++ status = "disabled"; ++ #phy-cells = <1>; ++ }; ++ ++ ehci0: usb@4101000 { ++ compatible = "allwinner,sun20i-d1-ehci", ++ "generic-ehci"; ++ reg = <0x4101000 0x100>; ++ interrupts = <46 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_OHCI0>, ++ <&ccu CLK_BUS_EHCI0>, ++ <&ccu CLK_USB_OHCI0>; ++ resets = <&ccu RST_BUS_OHCI0>, ++ <&ccu RST_BUS_EHCI0>; ++ phys = <&usbphy 0>; ++ phy-names = "usb"; ++ status = "disabled"; ++ }; ++ ++ ohci0: usb@4101400 { ++ compatible = "allwinner,sun20i-d1-ohci", ++ "generic-ohci"; ++ reg = <0x4101400 0x100>; ++ interrupts = <47 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_OHCI0>, ++ <&ccu CLK_USB_OHCI0>; ++ resets = <&ccu RST_BUS_OHCI0>; ++ phys = <&usbphy 0>; ++ phy-names = "usb"; ++ status = "disabled"; ++ }; ++ ++ ehci1: usb@4200000 { ++ compatible = "allwinner,sun20i-d1-ehci", ++ "generic-ehci"; ++ reg = <0x4200000 0x100>; ++ interrupts = <49 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_OHCI1>, ++ <&ccu CLK_BUS_EHCI1>, ++ <&ccu CLK_USB_OHCI1>; ++ resets = <&ccu RST_BUS_OHCI1>, ++ <&ccu RST_BUS_EHCI1>; ++ phys = <&usbphy 1>; ++ phy-names = "usb"; ++ status = "disabled"; ++ }; ++ ++ ohci1: usb@4200400 { ++ compatible = "allwinner,sun20i-d1-ohci", ++ "generic-ohci"; ++ reg = <0x4200400 0x100>; ++ interrupts = <50 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_OHCI1>, ++ <&ccu CLK_USB_OHCI1>; ++ resets = <&ccu RST_BUS_OHCI1>; ++ phys = <&usbphy 1>; ++ phy-names = "usb"; ++ status = "disabled"; ++ }; ++ ++ emac: ethernet@4500000 { ++ compatible = "allwinner,sun20i-d1-emac", ++ "allwinner,sun50i-a64-emac"; ++ reg = <0x4500000 0x10000>; ++ interrupts = <62 IRQ_TYPE_LEVEL_HIGH>; ++ interrupt-names = "macirq"; ++ clocks = <&ccu CLK_BUS_EMAC>; ++ clock-names = "stmmaceth"; ++ resets = <&ccu RST_BUS_EMAC>; ++ reset-names = "stmmaceth"; ++ syscon = <&syscon>; ++ status = "disabled"; ++ ++ mdio: mdio { ++ compatible = "snps,dwmac-mdio"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ }; ++ ++ display_clocks: clock-controller@5000000 { ++ compatible = "allwinner,sun20i-d1-de2-clk", ++ "allwinner,sun50i-h5-de2-clk"; ++ reg = <0x5000000 0x10000>; ++ clocks = <&ccu CLK_BUS_DE>, <&ccu CLK_DE>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_DE>; ++ #clock-cells = <1>; ++ #reset-cells = <1>; ++ }; ++ ++ mixer0: mixer@5100000 { ++ compatible = "allwinner,sun20i-d1-de2-mixer-0"; ++ reg = <0x5100000 0x100000>; ++ clocks = <&display_clocks CLK_BUS_MIXER0>, ++ <&display_clocks CLK_MIXER0>; ++ clock-names = "bus", "mod"; ++ resets = <&display_clocks RST_MIXER0>; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ mixer0_out: port@1 { ++ reg = <1>; ++ ++ mixer0_out_tcon_top_mixer0: endpoint { ++ remote-endpoint = <&tcon_top_mixer0_in_mixer0>; ++ }; ++ }; ++ }; ++ }; ++ ++ mixer1: mixer@5200000 { ++ compatible = "allwinner,sun20i-d1-de2-mixer-1"; ++ reg = <0x5200000 0x100000>; ++ clocks = <&display_clocks CLK_BUS_MIXER1>, ++ <&display_clocks CLK_MIXER1>; ++ clock-names = "bus", "mod"; ++ resets = <&display_clocks RST_MIXER1>; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ mixer1_out: port@1 { ++ reg = <1>; ++ ++ mixer1_out_tcon_top_mixer1: endpoint { ++ remote-endpoint = <&tcon_top_mixer1_in_mixer1>; ++ }; ++ }; ++ }; ++ }; ++ ++ tcon_top: tcon-top@5460000 { ++ compatible = "allwinner,sun20i-d1-tcon-top"; ++ reg = <0x5460000 0x1000>; ++ clocks = <&ccu CLK_BUS_DPSS_TOP>, ++ <&ccu CLK_TCON_TV>, ++ <&ccu CLK_TVE>, ++ <&ccu CLK_TCON_LCD0>; ++ clock-names = "bus", "tcon-tv0", "tve0", "dsi"; ++ clock-output-names = "tcon-top-tv0", "tcon-top-dsi"; ++ resets = <&ccu RST_BUS_DPSS_TOP>; ++ #clock-cells = <1>; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_top_mixer0_in: port@0 { ++ reg = <0>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_top_mixer0_in_mixer0: endpoint@0 { ++ reg = <0>; ++ remote-endpoint = <&mixer0_out_tcon_top_mixer0>; ++ }; ++ }; ++ ++ tcon_top_mixer0_out: port@1 { ++ reg = <1>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_top_mixer0_out_tcon_lcd0: endpoint@0 { ++ reg = <0>; ++ remote-endpoint = <&tcon_lcd0_in_tcon_top_mixer0>; ++ }; ++ ++ tcon_top_mixer0_out_tcon_tv0: endpoint@2 { ++ reg = <2>; ++ remote-endpoint = <&tcon_tv0_in_tcon_top_mixer0>; ++ }; ++ }; ++ ++ tcon_top_mixer1_in: port@2 { ++ reg = <2>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_top_mixer1_in_mixer1: endpoint@1 { ++ reg = <1>; ++ remote-endpoint = <&mixer1_out_tcon_top_mixer1>; ++ }; ++ }; ++ ++ tcon_top_mixer1_out: port@3 { ++ reg = <3>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_top_mixer1_out_tcon_lcd0: endpoint@0 { ++ reg = <0>; ++ remote-endpoint = <&tcon_lcd0_in_tcon_top_mixer1>; ++ }; ++ ++ tcon_top_mixer1_out_tcon_tv0: endpoint@2 { ++ reg = <2>; ++ remote-endpoint = <&tcon_tv0_in_tcon_top_mixer1>; ++ }; ++ }; ++ ++ tcon_top_hdmi_in: port@4 { ++ reg = <4>; ++ ++ tcon_top_hdmi_in_tcon_tv0: endpoint { ++ remote-endpoint = <&tcon_tv0_out_tcon_top_hdmi>; ++ }; ++ }; ++ ++ tcon_top_hdmi_out: port@5 { ++ reg = <5>; ++ }; ++ }; ++ }; ++ ++ tcon_lcd0: lcd-controller@5461000 { ++ compatible = "allwinner,sun20i-d1-tcon-lcd"; ++ reg = <0x5461000 0x1000>; ++ interrupts = <106 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_TCON_LCD0>, ++ <&ccu CLK_TCON_LCD0>; ++ clock-names = "ahb", "tcon-ch0"; ++ clock-output-names = "tcon-pixel-clock"; ++ resets = <&ccu RST_BUS_TCON_LCD0>, ++ <&ccu RST_BUS_LVDS0>; ++ reset-names = "lcd", "lvds"; ++ #clock-cells = <0>; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_lcd0_in: port@0 { ++ reg = <0>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_lcd0_in_tcon_top_mixer0: endpoint@0 { ++ reg = <0>; ++ remote-endpoint = <&tcon_top_mixer0_out_tcon_lcd0>; ++ }; ++ ++ tcon_lcd0_in_tcon_top_mixer1: endpoint@1 { ++ reg = <1>; ++ remote-endpoint = <&tcon_top_mixer1_out_tcon_lcd0>; ++ }; ++ }; ++ ++ tcon_lcd0_out: port@1 { ++ reg = <1>; ++ }; ++ }; ++ }; ++ ++ tcon_tv0: lcd-controller@5470000 { ++ compatible = "allwinner,sun20i-d1-tcon-tv"; ++ reg = <0x5470000 0x1000>; ++ interrupts = <107 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_TCON_TV>, ++ <&tcon_top CLK_TCON_TOP_TV0>; ++ clock-names = "ahb", "tcon-ch1"; ++ resets = <&ccu RST_BUS_TCON_TV>; ++ reset-names = "lcd"; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_tv0_in: port@0 { ++ reg = <0>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_tv0_in_tcon_top_mixer0: endpoint@0 { ++ reg = <0>; ++ remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>; ++ }; ++ ++ tcon_tv0_in_tcon_top_mixer1: endpoint@1 { ++ reg = <1>; ++ remote-endpoint = <&tcon_top_mixer1_out_tcon_tv0>; ++ }; ++ }; ++ ++ tcon_tv0_out: port@1 { ++ reg = <1>; ++ ++ tcon_tv0_out_tcon_top_hdmi: endpoint { ++ remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>; ++ }; ++ }; ++ }; ++ }; ++ ++ riscv_wdt: watchdog@6011000 { ++ compatible = "allwinner,sun20i-d1-wdt"; ++ reg = <0x6011000 0x20>; ++ interrupts = <147 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>, <&rtc CLK_OSC32K>; ++ clock-names = "hosc", "losc"; ++ }; ++ ++ r_ccu: clock-controller@7010000 { ++ compatible = "allwinner,sun20i-d1-r-ccu"; ++ reg = <0x7010000 0x400>; ++ clocks = <&osc24M>, ++ <&rtc CLK_OSC32K>, ++ <&rtc CLK_IOSC>, ++ <&ccu CLK_PLL_PERIPH0_DIV3>; ++ clock-names = "hosc", "losc", "iosc", "pll-periph"; ++ #clock-cells = <1>; ++ #reset-cells = <1>; ++ }; ++ ++ rtc: rtc@7090000 { ++ compatible = "allwinner,sun20i-d1-rtc", ++ "allwinner,sun50i-r329-rtc"; ++ reg = <0x7090000 0x400>; ++ interrupts = <160 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&r_ccu CLK_BUS_R_RTC>, ++ <&osc24M>, ++ <&r_ccu CLK_R_AHB>; ++ clock-names = "bus", "hosc", "ahb"; ++ #clock-cells = <1>; ++ }; ++ ++ plic: interrupt-controller@10000000 { ++ compatible = "allwinner,sun20i-d1-plic", ++ "thead,c900-plic"; ++ reg = <0x10000000 0x4000000>; ++ interrupts-extended = <&cpu0_intc 11>, ++ <&cpu0_intc 9>; ++ interrupt-controller; ++ riscv,ndev = <176>; ++ #address-cells = <0>; ++ #interrupt-cells = <2>; ++ }; ++ }; ++}; +--- /dev/null ++++ b/arch/riscv/dts/sunxi-u-boot.dtsi +@@ -0,0 +1,68 @@ ++// SPDX-License-Identifier: (GPL-2.0 OR MIT) ++ ++#include "binman.dtsi" ++ ++/ { ++ cpus { ++ u-boot,dm-spl; ++ }; ++ ++ soc { ++ u-boot,dm-spl; ++ }; ++}; ++ ++&binman { ++ u-boot-sunxi-with-spl { ++ filename = "u-boot-sunxi-with-spl.bin"; ++ pad-byte = <0xff>; ++ ++ blob@0 { ++ filename = "spl/sunxi-spl.bin"; ++ }; ++ ++ blob@1 { ++ filename = "u-boot.itb"; ++ }; ++ }; ++}; ++ ++&ccu { ++ u-boot,dm-spl; ++}; ++ ++&cpu0 { ++ u-boot,dm-spl; ++}; ++ ++&mbus { ++ u-boot,dm-spl; ++}; ++ ++&mmc0 { ++ u-boot,dm-spl; ++}; ++ ++&mmc0_pins { ++ u-boot,dm-spl; ++}; ++ ++&osc24M { ++ u-boot,dm-spl; ++}; ++ ++&pio { ++ u-boot,dm-spl; ++}; ++ ++&rtc { ++ u-boot,dm-spl; ++}; ++ ++&uart0 { ++ u-boot,dm-spl; ++}; ++ ++&uart0_pb8_pins { ++ u-boot,dm-spl; ++}; +--- /dev/null ++++ b/include/dt-bindings/clock/sun20i-d1-r-ccu.h +@@ -0,0 +1,19 @@ ++/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */ ++/* ++ * Copyright (C) 2021 Samuel Holland ++ */ ++ ++#ifndef _DT_BINDINGS_CLK_SUN20I_D1_R_CCU_H_ ++#define _DT_BINDINGS_CLK_SUN20I_D1_R_CCU_H_ ++ ++#define CLK_R_AHB 0 ++ ++#define CLK_BUS_R_TIMER 2 ++#define CLK_BUS_R_TWD 3 ++#define CLK_BUS_R_PPU 4 ++#define CLK_R_IR_RX 5 ++#define CLK_BUS_R_IR_RX 6 ++#define CLK_BUS_R_RTC 7 ++#define CLK_BUS_R_CPUCFG 8 ++ ++#endif /* _DT_BINDINGS_CLK_SUN20I_D1_R_CCU_H_ */ +--- /dev/null ++++ b/include/dt-bindings/reset/sun20i-d1-r-ccu.h +@@ -0,0 +1,16 @@ ++/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */ ++/* ++ * Copyright (C) 2021 Samuel Holland ++ */ ++ ++#ifndef _DT_BINDINGS_RST_SUN20I_D1_R_CCU_H_ ++#define _DT_BINDINGS_RST_SUN20I_D1_R_CCU_H_ ++ ++#define RST_BUS_R_TIMER 0 ++#define RST_BUS_R_TWD 1 ++#define RST_BUS_R_PPU 2 ++#define RST_BUS_R_IR_RX 3 ++#define RST_BUS_R_RTC 4 ++#define RST_BUS_R_CPUCFG 5 ++ ++#endif /* _DT_BINDINGS_RST_SUN20I_D1_R_CCU_H_ */ diff --git a/package/boot/uboot-d1/patches/0079-riscv-Add-CONFIG_TARGET_SUN20I_D1.patch b/package/boot/uboot-d1/patches/0079-riscv-Add-CONFIG_TARGET_SUN20I_D1.patch new file mode 100644 index 00000000000000..a3678243c14523 --- /dev/null +++ b/package/boot/uboot-d1/patches/0079-riscv-Add-CONFIG_TARGET_SUN20I_D1.patch @@ -0,0 +1,169 @@ +From 6b0c83a5c7b9189fb1c5cf56145ec4882d9e5588 Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 18:13:34 +0000 +Subject: [PATCH 79/90] riscv: Add CONFIG_TARGET_SUN20I_D1 + +Signed-off-by: Samuel Holland +Signed-off-by: Zoltan HERPAI +--- + arch/riscv/Kconfig | 5 +++++ + board/sunxi/Kconfig | 30 +++++++++++++++++++++++++++--- + common/spl/Kconfig | 1 + + drivers/clk/sunxi/Kconfig | 1 + + include/configs/sun20i.h | 11 +++++++++++ + 5 files changed, 45 insertions(+), 3 deletions(-) + create mode 100644 include/configs/sun20i.h + +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -31,6 +31,11 @@ config TARGET_SIPEED_MAIX + bool "Support Sipeed Maix Board" + select SYS_CACHE_SHIFT_6 + ++config TARGET_SUN20I_D1 ++ bool "Support Allwinner D1 Boards" ++ select BOARD_SUNXI ++ select SYS_CACHE_SHIFT_6 ++ + endchoice + + config SYS_ICACHE_OFF +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -13,8 +13,18 @@ config BOARD_SUNXI + select DM_SERIAL if SERIAL + select DM_SPI if SPI + select DM_SPI_FLASH if SPI ++ select GENERIC_RISCV if RISCV + select OF_BOARD_SETUP + select PINCTRL ++ select RAM if SPL_DM ++ select SPL_CLK if SPL_DM ++ select SPL_DM if RISCV && SPL ++ select SPL_DM_SPI if SPL_DM && SPL_SPI ++ select SPL_DM_SPI_FLASH if SPL_DM && SPL_SPI ++ select SPL_OF_CONTROL if SPL_DM ++ select SPL_PINCTRL if SPL_DM ++ select SPL_PINCONF if SPL_DM ++ select SPL_RAM if SPL_DM + select SPL_SEPARATE_BSS if SPL + select SUPPORT_SPL + select SYS_RELOC_GD_ENV_ADDR +@@ -28,12 +38,14 @@ config BOARD_SUNXI + imply DISTRO_DEFAULTS + imply FAT_WRITE + imply FIT ++ imply MMC + imply OF_LIBFDT_OVERLAY + imply PRE_CONSOLE_BUFFER + imply SPL + imply SPL_GPIO + imply SPL_LIBCOMMON_SUPPORT + imply SPL_LIBGENERIC_SUPPORT ++ imply SPL_LOAD_FIT + imply SPL_MMC if MMC + imply SPL_POWER + imply SPL_SERIAL +@@ -41,6 +53,7 @@ config BOARD_SUNXI + imply SYS_I2C_MVTWSI + imply SYS_NS16550 + imply SYSRESET ++ imply SYSRESET_SBI + imply SYSRESET_WATCHDOG + imply SYSRESET_WATCHDOG_AUTO + imply USB_EHCI_GENERIC +@@ -67,6 +80,12 @@ config SPL_BSS_START_ADDR + default 0x4ff80000 if SUNXI_MINIMUM_DRAM_MB >= 256 + default 0x43f80000 if SUNXI_MINIMUM_DRAM_MB >= 64 + ++config SPL_OPENSBI_LOAD_ADDR ++ default 0x40000000 if RISCV ++ ++config SPL_STACK ++ default 0x48000 if TARGET_SUN20I_D1 ++ + config SPL_STACK_R_ADDR + default 0x81e00000 if MACH_SUNIV + default 0x2fe00000 if MACH_SUN9I +@@ -75,13 +94,13 @@ config SPL_STACK_R_ADDR + + config SPL_TEXT_BASE + default 0x10060 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 +- default 0x20060 if SUN50I_GEN_H6 ++ default 0x20060 if SUN50I_GEN_H6 || TARGET_SUN20I_D1 + default 0x00060 + + config SUNXI_MINIMUM_DRAM_MB + int + default 32 if MACH_SUNIV +- default 64 if MACH_SUN8I_V3S ++ default 64 if MACH_SUN8I_V3S || TARGET_SUN20I_D1 + default 256 + help + Minimum DRAM size expected on the board. Traditionally we +@@ -94,7 +113,7 @@ config SUNXI_MINIMUM_DRAM_MB + config SUNXI_SRAM_ADDRESS + hex + default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 +- default 0x20000 if SUN50I_GEN_H6 ++ default 0x20000 if SUN50I_GEN_H6 || TARGET_SUN20I_D1 + default 0x0 + help + Older Allwinner SoCs have their boot mask ROM mapped just +@@ -113,6 +132,7 @@ config SYS_CLK_FREQ + default 912000000 if MACH_SUN7I + default 1008000000 if MACH_SUN8I + default 1008000000 if MACH_SUN9I ++ default 1008000000 if TARGET_SUN20I_D1 + default 816000000 if MACH_SUN50I || MACH_SUN50I_H5 + default 888000000 if MACH_SUN50I_H6 + default 1008000000 if MACH_SUN50I_H616 +@@ -125,10 +145,14 @@ config SYS_CONFIG_NAME + default "sun7i" if MACH_SUN7I + default "sun8i" if MACH_SUN8I + default "sun9i" if MACH_SUN9I ++ default "sun20i" if TARGET_SUN20I_D1 + default "sun50i" if MACH_SUN50I + default "sun50i" if MACH_SUN50I_H6 + default "sun50i" if MACH_SUN50I_H616 + ++config SYS_CPU ++ default "generic" if TARGET_SUN20I_D1 ++ + config SYS_LOAD_ADDR + default 0x81000000 if MACH_SUNIV + default 0x22000000 if MACH_SUN9I +--- a/common/spl/Kconfig ++++ b/common/spl/Kconfig +@@ -78,6 +78,7 @@ config SPL_MAX_SIZE + hex "Maximum size of the SPL image, excluding BSS" + default 0x37fa0 if MACH_SUN50I_H616 + default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB ++ default 0x27fa0 if TARGET_SUN20I_D1 + default 0x25fa0 if MACH_SUN50I_H6 + default 0x1b000 if AM33XX && !TI_SECURE_DEVICE + default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB +--- a/drivers/clk/sunxi/Kconfig ++++ b/drivers/clk/sunxi/Kconfig +@@ -98,6 +98,7 @@ config CLK_SUN8I_H3 + + config CLK_SUN20I_D1 + bool "Clock driver for Allwinner D1" ++ default TARGET_SUN20I_D1 + help + This enables common clock driver support for platforms based + on Allwinner D1 SoC. +--- /dev/null ++++ b/include/configs/sun20i.h +@@ -0,0 +1,11 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Placeholder wrapper to allow addressing Allwinner D1 (and later) sun20i ++ * CPU based devices separately. Please do not add anything in here. ++ */ ++#ifndef __CONFIG_H ++#define __CONFIG_H ++ ++#include ++ ++#endif /* __CONFIG_H */ diff --git a/package/boot/uboot-d1/patches/0080-gpio-sunxi-Hack-up-the-driver-for-the-D1.patch b/package/boot/uboot-d1/patches/0080-gpio-sunxi-Hack-up-the-driver-for-the-D1.patch new file mode 100644 index 00000000000000..42a5c28584499a --- /dev/null +++ b/package/boot/uboot-d1/patches/0080-gpio-sunxi-Hack-up-the-driver-for-the-D1.patch @@ -0,0 +1,134 @@ +From 28682ca027b9fa64f3de4cea99373642f36c4e6c Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 8 Aug 2021 19:32:14 -0500 +Subject: [PATCH 80/90] gpio: sunxi: Hack up the driver for the D1 + +Signed-off-by: Samuel Holland +--- + arch/arm/include/asm/arch-sunxi/gpio.h | 12 ++++++++++-- + arch/arm/mach-sunxi/pinmux.c | 8 +++++++- + drivers/gpio/sunxi_gpio.c | 3 +++ + 3 files changed, 20 insertions(+), 3 deletions(-) + +--- a/arch/arm/include/asm/arch-sunxi/gpio.h ++++ b/arch/arm/include/asm/arch-sunxi/gpio.h +@@ -9,7 +9,9 @@ + #define _SUNXI_GPIO_H + + #include ++#if 0 + #include ++#endif + + /* + * sunxi has 9 banks of gpio, they are: +@@ -55,30 +57,36 @@ + struct sunxi_gpio { + u32 cfg[4]; + u32 dat; +- u32 drv[2]; ++ u32 drv[4]; + u32 pull[2]; ++ u32 reserved; + }; + + /* gpio interrupt control */ + struct sunxi_gpio_int { +- u32 cfg[3]; ++ u32 cfg[4]; + u32 ctl; + u32 sta; + u32 deb; /* interrupt debounce */ ++ u32 reserved; + }; + ++#if 0 + struct sunxi_gpio_reg { + struct sunxi_gpio gpio_bank[SUNXI_GPIO_BANKS]; + u8 res[0xbc]; + struct sunxi_gpio_int gpio_int; + }; ++#endif + + #define SUN50I_H6_GPIO_POW_MOD_SEL 0x340 + #define SUN50I_H6_GPIO_POW_MOD_VAL 0x348 + ++#if 0 + #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]) ++#endif + + #define GPIO_BANK(pin) ((pin) >> 5) + #define GPIO_NUM(pin) ((pin) & 0x1f) +--- a/arch/arm/mach-sunxi/pinmux.c ++++ b/arch/arm/mach-sunxi/pinmux.c +@@ -7,7 +7,7 @@ + + #include + #include +-#include ++//#include + + void sunxi_gpio_set_cfgbank(struct sunxi_gpio *pio, int bank_offset, u32 val) + { +@@ -17,6 +17,7 @@ void sunxi_gpio_set_cfgbank(struct sunxi + clrsetbits_le32(&pio->cfg[index], 0xf << offset, val << offset); + } + ++#if !CONFIG_IS_ENABLED(DM_GPIO) + void sunxi_gpio_set_cfgpin(u32 pin, u32 val) + { + u32 bank = GPIO_BANK(pin); +@@ -24,6 +25,7 @@ void sunxi_gpio_set_cfgpin(u32 pin, u32 + + sunxi_gpio_set_cfgbank(pio, pin, val); + } ++#endif + + int sunxi_gpio_get_cfgbank(struct sunxi_gpio *pio, int bank_offset) + { +@@ -37,6 +39,7 @@ int sunxi_gpio_get_cfgbank(struct sunxi_ + return cfg & 0xf; + } + ++#if !CONFIG_IS_ENABLED(DM_GPIO) + int sunxi_gpio_get_cfgpin(u32 pin) + { + u32 bank = GPIO_BANK(pin); +@@ -52,6 +55,7 @@ void sunxi_gpio_set_drv(u32 pin, u32 val + + sunxi_gpio_set_drv_bank(pio, pin, val); + } ++#endif + + void sunxi_gpio_set_drv_bank(struct sunxi_gpio *pio, u32 bank_offset, u32 val) + { +@@ -61,6 +65,7 @@ void sunxi_gpio_set_drv_bank(struct sunx + clrsetbits_le32(&pio->drv[index], 0x3 << offset, val << offset); + } + ++#if !CONFIG_IS_ENABLED(DM_GPIO) + void sunxi_gpio_set_pull(u32 pin, u32 val) + { + u32 bank = GPIO_BANK(pin); +@@ -68,6 +73,7 @@ void sunxi_gpio_set_pull(u32 pin, u32 va + + sunxi_gpio_set_pull_bank(pio, pin, val); + } ++#endif + + void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val) + { +--- a/drivers/gpio/sunxi_gpio.c ++++ b/drivers/gpio/sunxi_gpio.c +@@ -18,6 +18,9 @@ + #include + #include + ++#include "../../arch/arm/include/asm/arch-sunxi/gpio.h" ++#include "../../arch/arm/mach-sunxi/pinmux.c" ++ + #if !CONFIG_IS_ENABLED(DM_GPIO) + static int sunxi_gpio_output(u32 pin, u32 val) + { diff --git a/package/boot/uboot-d1/patches/0081-mmc-sunxi-Hack-up-the-driver-for-the-D1.patch b/package/boot/uboot-d1/patches/0081-mmc-sunxi-Hack-up-the-driver-for-the-D1.patch new file mode 100644 index 00000000000000..3d8ddf45838e83 --- /dev/null +++ b/package/boot/uboot-d1/patches/0081-mmc-sunxi-Hack-up-the-driver-for-the-D1.patch @@ -0,0 +1,118 @@ +From 4df80766531bc35510981ebc5ea0bb07264beac9 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 8 Aug 2021 19:31:20 -0500 +Subject: [PATCH 81/90] mmc: sunxi: Hack up the driver for the D1 + +Signed-off-by: Samuel Holland +--- + arch/riscv/include/asm/io.h | 1 + + drivers/mmc/sunxi_mmc.c | 29 +++++++++++++++++++++++++---- + drivers/mmc/sunxi_mmc.h | 2 -- + 3 files changed, 26 insertions(+), 6 deletions(-) + +--- a/arch/riscv/include/asm/io.h ++++ b/arch/riscv/include/asm/io.h +@@ -85,6 +85,7 @@ static inline u16 readw(const volatile v + return val; + } + ++#define readl_relaxed readl + static inline u32 readl(const volatile void __iomem *addr) + { + u32 val; +--- a/drivers/mmc/sunxi_mmc.c ++++ b/drivers/mmc/sunxi_mmc.c +@@ -23,9 +23,9 @@ + #include + #include + #include ++#if !CONFIG_IS_ENABLED(DM_MMC) + #include + #include +-#if !CONFIG_IS_ENABLED(DM_MMC) + #include + #endif + #include +@@ -36,6 +36,23 @@ + #define CCM_MMC_CTRL_MODE_SEL_NEW 0 + #endif + ++#include "../../arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h" ++ ++unsigned int clock_get_pll6(void) ++{ ++ uint32_t rval = readl((void *)0x2001020); ++ ++ int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT) + 1; ++ int m = ((rval >> 1) & 0x1) + 1; ++ int p0 = ((rval >> 16) & 0x7) + 1; ++ /* The register defines PLL6-2X, not plain PLL6 */ ++ uint32_t freq = 24000000UL * n / m / p0; ++ ++ printf("PLL reg = 0x%08x, freq = %d\n", rval, freq); ++ ++ return freq; ++} ++ + struct sunxi_mmc_plat { + struct mmc_config cfg; + struct mmc mmc; +@@ -60,7 +77,8 @@ static bool sunxi_mmc_can_calibrate(void + return IS_ENABLED(CONFIG_MACH_SUN50I) || + IS_ENABLED(CONFIG_MACH_SUN50I_H5) || + IS_ENABLED(CONFIG_SUN50I_GEN_H6) || +- IS_ENABLED(CONFIG_MACH_SUN8I_R40); ++ IS_ENABLED(CONFIG_MACH_SUN8I_R40) || ++ IS_ENABLED(CONFIG_TARGET_SUN20I_D1); + } + + static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz) +@@ -194,7 +212,7 @@ static int mmc_config_clock(struct sunxi + rval &= ~SUNXI_MMC_CLK_DIVIDER_MASK; + writel(rval, &priv->reg->clkcr); + +-#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_SUN50I_GEN_H6) ++#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_SUN50I_GEN_H6) || defined(CONFIG_TARGET_SUN20I_D1) + /* A64 supports calibration of delays on MMC controller and we + * have to set delay of zero before starting calibration. + * Allwinner BSP driver sets a delay only in the case of +@@ -622,7 +640,8 @@ static unsigned get_mclk_offset(void) + if (IS_ENABLED(CONFIG_MACH_SUN9I_A80)) + return 0x410; + +- if (IS_ENABLED(CONFIG_SUN50I_GEN_H6)) ++ if (IS_ENABLED(CONFIG_SUN50I_GEN_H6) || ++ IS_ENABLED(CONFIG_TARGET_SUN20I_D1)) + return 0x830; + + return 0x88; +@@ -662,6 +681,7 @@ static int sunxi_mmc_probe(struct udevic + return ret; + ccu_reg = (u32 *)(uintptr_t)ofnode_get_addr(args.node); + ++#define SUNXI_MMC0_BASE 0x4020000 + priv->mmc_no = ((uintptr_t)priv->reg - SUNXI_MMC0_BASE) / 0x1000; + priv->mclkreg = (void *)ccu_reg + get_mclk_offset() + priv->mmc_no * 4; + +@@ -703,6 +723,7 @@ static const struct udevice_id sunxi_mmc + { .compatible = "allwinner,sun7i-a20-mmc" }, + { .compatible = "allwinner,sun8i-a83t-emmc" }, + { .compatible = "allwinner,sun9i-a80-mmc" }, ++ { .compatible = "allwinner,sun20i-d1-mmc" }, + { .compatible = "allwinner,sun50i-a64-mmc" }, + { .compatible = "allwinner,sun50i-a64-emmc" }, + { .compatible = "allwinner,sun50i-h6-mmc" }, +--- a/drivers/mmc/sunxi_mmc.h ++++ b/drivers/mmc/sunxi_mmc.h +@@ -45,11 +45,9 @@ struct sunxi_mmc { + u32 chda; /* 0x90 */ + u32 cbda; /* 0x94 */ + u32 res2[26]; +-#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_SUN50I_GEN_H6) + u32 res3[17]; + u32 samp_dl; + u32 res4[46]; +-#endif + u32 fifo; /* 0x100 / 0x200 FIFO access address */ + }; + diff --git a/package/boot/uboot-d1/patches/0082-pinctrl-sunxi-Hack-up-the-driver-for-the-D1.patch b/package/boot/uboot-d1/patches/0082-pinctrl-sunxi-Hack-up-the-driver-for-the-D1.patch new file mode 100644 index 00000000000000..06502d3186d801 --- /dev/null +++ b/package/boot/uboot-d1/patches/0082-pinctrl-sunxi-Hack-up-the-driver-for-the-D1.patch @@ -0,0 +1,29 @@ +From c33ca5c6a5be74711460756bf86c45b6c6fd0a3f Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 4 Nov 2021 17:49:15 -0500 +Subject: [PATCH 82/90] pinctrl: sunxi: Hack up the driver for the D1 + +Signed-off-by: Samuel Holland +--- + drivers/pinctrl/sunxi/pinctrl-sunxi.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c ++++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c +@@ -9,6 +9,7 @@ + #include + + #include ++#include "../../../arch/arm/include/asm/arch-sunxi/gpio.h" + + extern U_BOOT_DRIVER(gpio_sunxi); + +@@ -49,7 +50,7 @@ static const char *sunxi_pinctrl_get_pin + uint pin_selector) + { + const struct sunxi_pinctrl_desc *desc = dev_get_priv(dev); +- static char pin_name[sizeof("PN31")]; ++ static char pin_name[sizeof("PN31")] __section(".data"); + + snprintf(pin_name, sizeof(pin_name), "P%c%d", + pin_selector / SUNXI_GPIOS_PER_BANK + desc->first_bank + 'A', diff --git a/package/boot/uboot-d1/patches/0083-ram-sunxi-Add-Allwinner-D1-DRAM-driver.patch b/package/boot/uboot-d1/patches/0083-ram-sunxi-Add-Allwinner-D1-DRAM-driver.patch new file mode 100644 index 00000000000000..73e3b1060d4e53 --- /dev/null +++ b/package/boot/uboot-d1/patches/0083-ram-sunxi-Add-Allwinner-D1-DRAM-driver.patch @@ -0,0 +1,1943 @@ +From 9f612f3a1fd3d0759abca3720d488a17d159aa17 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sun, 30 Oct 2022 14:54:08 -0500 +Subject: [PATCH 83/90] ram: sunxi: Add Allwinner D1 DRAM driver + +Signed-off-by: Samuel Holland +--- + drivers/ram/Kconfig | 1 + + drivers/ram/Makefile | 1 + + drivers/ram/sunxi/Kconfig | 6 + + drivers/ram/sunxi/Makefile | 3 + + drivers/ram/sunxi/dram_v2.h | 65 + + drivers/ram/sunxi/mctl_hal-sun20iw1p1.c | 1771 +++++++++++++++++++++++ + drivers/ram/sunxi/sdram.h | 46 + + 7 files changed, 1893 insertions(+) + create mode 100644 drivers/ram/sunxi/Kconfig + create mode 100644 drivers/ram/sunxi/Makefile + create mode 100644 drivers/ram/sunxi/dram_v2.h + create mode 100644 drivers/ram/sunxi/mctl_hal-sun20iw1p1.c + create mode 100644 drivers/ram/sunxi/sdram.h + +--- a/drivers/ram/Kconfig ++++ b/drivers/ram/Kconfig +@@ -101,3 +101,4 @@ source "drivers/ram/rockchip/Kconfig" + source "drivers/ram/sifive/Kconfig" + source "drivers/ram/stm32mp1/Kconfig" + source "drivers/ram/octeon/Kconfig" ++source "drivers/ram/sunxi/Kconfig" +--- a/drivers/ram/Makefile ++++ b/drivers/ram/Makefile +@@ -20,5 +20,6 @@ obj-$(CONFIG_K3_DDRSS) += k3-ddrss/ + obj-$(CONFIG_IMXRT_SDRAM) += imxrt_sdram.o + + obj-$(CONFIG_RAM_SIFIVE) += sifive/ ++obj-$(CONFIG_RAM_SUNXI) += sunxi/ + + obj-$(CONFIG_ARCH_OCTEON) += octeon/ +--- /dev/null ++++ b/drivers/ram/sunxi/Kconfig +@@ -0,0 +1,6 @@ ++config RAM_SUNXI ++ bool "Ram drivers support for sunxi SoCs" ++ depends on RAM && BOARD_SUNXI ++ default y ++ help ++ This enables support for ram drivers of sunxi SoCs. +--- /dev/null ++++ b/drivers/ram/sunxi/Makefile +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: GPL-2.0+ ++ ++obj-$(CONFIG_RAM_SUNXI) += mctl_hal-sun20iw1p1.o +--- /dev/null ++++ b/drivers/ram/sunxi/dram_v2.h +@@ -0,0 +1,65 @@ ++/* ++ * (C) Copyright 2007-2013 ++* SPDX-License-Identifier: GPL-2.0+ ++ * Allwinner Technology Co., Ltd. ++ * Jerry Wang ++ * ++ * See file CREDITS for list of people who contributed to this ++ * project. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of ++ * the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that 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, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, ++ * MA 02111-1307 USA ++ */ ++ ++#ifndef __dram_head_h__ ++#define __dram_head_h__ ++ ++struct dram_para_t ++{ ++ //normal configuration ++ unsigned int dram_clk; ++ unsigned int dram_type; //dram_type DDR2: 2 DDR3: 3 LPDDR2: 6 LPDDR3: 7 DDR3L: 31 ++ //unsigned int lpddr2_type; //LPDDR2 type S4:0 S2:1 NVM:2 ++ unsigned int dram_zq; //do not need ++ unsigned int dram_odt_en; ++ ++ //control configuration ++ unsigned int dram_para1; ++ unsigned int dram_para2; ++ ++ //timing configuration ++ unsigned int dram_mr0; ++ unsigned int dram_mr1; ++ unsigned int dram_mr2; ++ unsigned int dram_mr3; ++ unsigned int dram_tpr0; //DRAMTMG0 ++ unsigned int dram_tpr1; //DRAMTMG1 ++ unsigned int dram_tpr2; //DRAMTMG2 ++ unsigned int dram_tpr3; //DRAMTMG3 ++ unsigned int dram_tpr4; //DRAMTMG4 ++ unsigned int dram_tpr5; //DRAMTMG5 ++ unsigned int dram_tpr6; //DRAMTMG8 ++ //reserved for future use ++ unsigned int dram_tpr7; ++ unsigned int dram_tpr8; ++ unsigned int dram_tpr9; ++ unsigned int dram_tpr10; ++ unsigned int dram_tpr11; ++ unsigned int dram_tpr12; ++ unsigned int dram_tpr13; ++ ++}; ++ ++#endif +--- /dev/null ++++ b/drivers/ram/sunxi/mctl_hal-sun20iw1p1.c +@@ -0,0 +1,1771 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++#include ++#include ++#include ++#include ++ ++#include "dram_v2.h" ++#include "sdram.h" ++ ++#define readl rv_readl ++#define writel rv_writel ++#include ++#undef readl ++#undef writel ++ ++#define readl(x) rv_readl((const volatile void __iomem *)(u64)(x)) ++#define writel(x, v) rv_writel(v, (volatile void __iomem *)(u64)(x)) ++ ++#if defined(CONFIG_SPL_BUILD) ++ ++char* memcpy_self(char* dst, char* src, int len) ++{ ++ int i; ++ for(i=0; i!=len; i++) { ++ dst[i] = src[i]; ++ } ++ return dst; ++} ++ ++void dram_vol_set(struct dram_para_t *para) ++{ ++ int reg, vol = 0; ++ ++ switch( para->dram_type ) { ++ case 2: vol = 47; break; ++ case 3: vol = 25; break; ++ default: vol = 0; ++ } ++vol = 25; // XXX ++ reg = readl(0x3000150); ++ reg &= ~(0xff00); ++ reg |= vol << 8; ++ reg &= ~(0x200000); ++ writel(0x3000150, reg); ++ ++ udelay(1); ++} ++ ++void paraconfig(unsigned int *para, unsigned int mask, unsigned int value) ++{ ++ *para &= ~(mask); ++ *para |= value; ++} ++ ++ ++void dram_enable_all_master(void) ++{ ++ writel(0x3102020, -1); ++ writel(0x3102024, 0xff); ++ writel(0x3102028, 0xffff); ++ udelay(10); ++} ++ ++ ++void dram_disable_all_master(void) ++{ ++ writel(0x3102020, 1); ++ writel(0x3102024, 0); ++ writel(0x3102028, 0); ++ udelay(10); ++} ++ ++ ++void eye_delay_compensation(struct dram_para_t *para) // s1 ++{ ++ unsigned int val, ptr; ++ ++ // DATn0IOCR, n = 0...7 ++ for (ptr = 0x3103310; ptr != 0x3103334; ptr += 4) { ++ val = readl(ptr); ++ val |= (para->dram_tpr11 << 9) & 0x1e00; ++ val |= (para->dram_tpr12 << 1) & 0x001e; ++ writel(ptr, val); ++ } ++ ++ // DATn1IOCR, n = 0...7 ++ for (ptr = 0x3103390; ptr != 0x31033b4; ptr += 4) { ++ val = readl(ptr); ++ val |= ((para->dram_tpr11 >> 4) << 9) & 0x1e00; ++ val |= ((para->dram_tpr12 >> 4) << 1) & 0x001e; ++ writel(ptr, val); ++ } ++ ++ // PGCR0: assert AC loopback FIFO reset ++ val = readl(0x3103100); ++ val &= 0xfbffffff; ++ writel(0x3103100, val); ++ ++ // ?? ++ val = readl(0x3103334); ++ val |= ((para->dram_tpr11 >> 16) << 9) & 0x1e00; ++ val |= ((para->dram_tpr12 >> 16) << 1) & 0x001e; ++ writel(0x3103334, val); ++ ++ val = readl(0x3103338); ++ val |= ((para->dram_tpr11 >> 16) << 9) & 0x1e00; ++ val |= ((para->dram_tpr12 >> 16) << 1) & 0x001e; ++ writel(0x3103338, val); ++ ++ val = readl(0x31033b4); ++ val |= ((para->dram_tpr11 >> 20) << 9) & 0x1e00; ++ val |= ((para->dram_tpr12 >> 20) << 1) & 0x001e; ++ writel(0x31033b4, val); ++ ++ val = readl(0x31033b8); ++ val |= ((para->dram_tpr11 >> 20) << 9) & 0x1e00; ++ val |= ((para->dram_tpr12 >> 20) << 1) & 0x001e; ++ writel(0x31033b8, val); ++ ++ val = readl(0x310333c); ++ val |= ((para->dram_tpr11 >> 16) << 25) & 0x1e000000; ++ writel(0x310333c, val); ++ ++ val = readl(0x31033bc); ++ val |= ((para->dram_tpr11 >> 20) << 25) & 0x1e000000; ++ writel(0x31033bc, val); ++ ++ // PGCR0: release AC loopback FIFO reset ++ val = readl(0x3103100); ++ val |= 0x04000000; ++ writel(0x3103100, val); ++ ++ udelay(1); ++ ++ for (ptr = 0x3103240; ptr != 0x310327c; ptr += 4) { ++ val = readl(ptr); ++ val |= ((para->dram_tpr10 >> 4) << 8) & 0x0f00; ++ writel(ptr, val); ++ } ++ ++ for (ptr = 0x3103228; ptr != 0x3103240; ptr += 4) { ++ val = readl(ptr); ++ val |= ((para->dram_tpr10 >> 4) << 8) & 0x0f00; ++ writel(ptr, val); ++ } ++ ++ val = readl(0x3103218); ++ val |= (para->dram_tpr10 << 8) & 0x0f00; ++ writel(0x3103218, val); ++ ++ val = readl(0x310321c); ++ val |= (para->dram_tpr10 << 8) & 0x0f00; ++ writel(0x310321c, val); ++ ++ val = readl(0x3103280); ++ val |= ((para->dram_tpr10 >> 12) << 8) & 0x0f00; ++ writel(0x3103280, val); ++} ++ ++ ++// Not used ?? ++// ++void bit_delay_compensation(void) ++{ ++ const unsigned int data0[44] = { ++ 0, 1, 2, 3, 2, 3, 3, 3, 0, 0, 0, ++ 6, 6, 6, 5, 5, 5, 5, 5, 0, 0, 0, ++ 0, 2, 4, 2, 6, 5, 5, 5, 0, 0, 0, ++ 3, 3, 3, 2, 2, 1, 1, 1, 0, 0, 0, ++ }; ++ const unsigned int data1[44] = { ++ 0, 1, 3, 3, 3, 3, 3, 4, 3, 3, 3, ++ 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, ++ 0, 3, 3, 1, 6, 6, 5, 6, 3, 3, 3, ++ 5, 5, 6, 6, 4, 5, 3, 3, 3, 3, 3, ++ }; ++ ++ unsigned int *start = (unsigned int *)0x3102310; // DATX0IOCR ++ unsigned int *end = (unsigned int *)0x3102510; // DATX0IOCR x + 4 * size ++ unsigned int *datxiocr; ++ unsigned int i, j, k, rval; ++ ++ rval = readl(0x3102100) & 0x03ffffff; ++ writel(0x3102100, rval); ++ ++ // Fill DATX0IOCR - DATX3IOCR, 11 registers per block, blocks 0x20 words apart ++ for(i = 0, datxiocr = start; datxiocr != end; i += 11, datxiocr += 0x20) { ++ for(j = 0, k = i; j != 11; j++, k++) { ++ rval = readl((unsigned int)datxiocr[j]); ++ rval += data1[k] << 8; ++ rval += data0[k]; ++ writel((unsigned int)datxiocr[j], rval); ++ } ++ } ++ ++ rval = readl(0x3102100) | 0x04000000; ++ writel(0x3102100, rval); ++} ++ ++// Not used ?? ++// ++void set_master_priority_pad(struct dram_para_t *para) ++{ ++ unsigned int val; ++ ++ val = readl(0x310200c) & 0xfffff000; ++ val |= (para->dram_clk >> 1) - 1; ++ writel(0x310200c, val); ++ ++ writel(0x3102200, 0x00001000); ++ writel(0x3102210, 0x01000009); ++ writel(0x3102214, 0x00500100); ++ writel(0x3102230, 0x0200000d); ++ writel(0x3102234, 0x00600100); ++ writel(0x3102240, 0x01000009); ++ writel(0x3102244, 0x00500100); ++ writel(0x3102260, 0x00640209); ++ writel(0x3102264, 0x00200040); ++ writel(0x3102290, 0x01000009); ++ writel(0x3102294, 0x00400080); ++ writel(0x3102470, 0); ++ writel(0x3102474, 0); ++ ++ writel(0x31031c0, 0x0f802f05); ++ writel(0x31031c8, 0x0f0000ff); ++ writel(0x31031d0, 0x3f00005f); ++} ++ ++int auto_cal_timing(unsigned int time, unsigned int freq) ++{ ++ unsigned int t = time*freq; ++ return t/1000 + ( ((t%1000) != 0) ? 1 : 0); ++} ++ ++// Main purpose of the auto_set_timing routine seems to be to calculate all ++// timing settings for the specific type of sdram used. Read together with ++// an sdram datasheet for context on the various variables. ++// ++void auto_set_timing_para(struct dram_para_t *para) // s5 ++{ ++ unsigned int freq; // s4 ++ unsigned int type; // s8 ++ unsigned int tpr13; // 80(sp) ++ unsigned int reg_val; ++ ++ unsigned char tccd; // 88(sp) ++ unsigned char trrd; // s7 ++ unsigned char trcd; // s3 ++ unsigned char trc; // s9 ++ unsigned char tfaw; // s10 ++ unsigned char tras; // s11 ++ unsigned char trp; // 0(sp) ++ unsigned char twtr; // s1 ++ unsigned char twr; // s6 ++ unsigned char trtp; // 64(sp) ++ unsigned char txp; // a6 ++ unsigned short trefi; // s2 ++ unsigned short trfc; // a5 / 8(sp) ++ ++ freq = para->dram_clk; ++ type = para->dram_type; ++ tpr13 = para->dram_tpr13; ++ ++ //printf("type = %d\n", type); ++ //printf("tpr13 = %p\n", tpr13); ++ ++ if (para->dram_tpr13 & 0x2) ++ { ++ //dram_tpr0 ++ tccd = ( (para->dram_tpr0 >> 21) & 0x7 ); // [23:21] ++ tfaw = ( (para->dram_tpr0 >> 15) & 0x3f ); // [20:15] ++ trrd = ( (para->dram_tpr0 >> 11) & 0xf ); // [14:11] ++ trcd = ( (para->dram_tpr0 >> 6) & 0x1f ); // [10:6 ] ++ trc = ( (para->dram_tpr0 >> 0) & 0x3f ); // [ 5:0 ] ++ //dram_tpr1 ++ txp = ( (para->dram_tpr1 >> 23) & 0x1f ); // [27:23] ++ twtr = ( (para->dram_tpr1 >> 20) & 0x7 ); // [22:20] ++ trtp = ( (para->dram_tpr1 >> 15) & 0x1f ); // [19:15] ++ twr = ( (para->dram_tpr1 >> 11) & 0xf ); // [14:11] ++ trp = ( (para->dram_tpr1 >> 6) & 0x1f ); // [10:6 ] ++ tras = ( (para->dram_tpr1 >> 0) & 0x3f ); // [ 5:0 ] ++ //dram_tpr2 ++ trfc = ( (para->dram_tpr2 >> 12)& 0x1ff); // [20:12] ++ trefi = ( (para->dram_tpr2 >> 0) & 0xfff); // [11:0 ] ++ } ++ else { ++ unsigned int frq2 = freq >> 1; // s0 ++ ++ if (type == 3) { ++ // DDR3 ++ trfc = auto_cal_timing( 350, frq2); ++ trefi = auto_cal_timing(7800, frq2) / 32 + 1; // XXX ++ twr = auto_cal_timing( 8, frq2); ++ trcd = auto_cal_timing( 15, frq2); ++ twtr = twr + 2; // + 2 ? XXX ++ if (twr < 2) twtr = 2; ++ twr = trcd; ++ if (trcd < 2) twr = 2; ++ if (freq <= 800) { ++ tfaw = auto_cal_timing(50, frq2); ++ trrd = auto_cal_timing(10, frq2); ++ if (trrd < 2) trrd = 2; ++ trc = auto_cal_timing(53, frq2); ++ tras = auto_cal_timing(38, frq2); ++ txp = trrd; // 10 ++ trp = trcd; // 15 ++ } ++ else { ++ tfaw = auto_cal_timing(35, frq2); ++ trrd = auto_cal_timing(10, frq2); ++ if (trrd < 2) trrd = 2; ++ trcd = auto_cal_timing(14, frq2); ++ trc = auto_cal_timing(48, frq2); ++ tras = auto_cal_timing(34, frq2); ++ txp = trrd; // 10 ++ trp = trcd; // 14 ++ } ++ } ++ else if (type == 2) { ++ // DDR2 ++ tfaw = auto_cal_timing( 50, frq2); ++ trrd = auto_cal_timing( 10, frq2); ++ trcd = auto_cal_timing( 20, frq2); ++ trc = auto_cal_timing( 65, frq2); ++ twtr = auto_cal_timing( 8, frq2); ++ trp = auto_cal_timing( 15, frq2); ++ tras = auto_cal_timing( 45, frq2); ++ trefi = auto_cal_timing(7800, frq2) / 32; ++ trfc = auto_cal_timing( 328, frq2); ++ txp = 2; ++ twr = trp; // 15 ++ } ++ else if (type == 6) { ++ // LPDDR2 ++ tfaw = auto_cal_timing( 50, frq2); ++ if (tfaw < 4) tfaw = 4; ++ trrd = auto_cal_timing( 10, frq2); ++ if (trrd == 0) trrd = 1; ++ trcd = auto_cal_timing( 24, frq2); ++ if (trcd < 2) trcd = 2; ++ trc = auto_cal_timing( 70, frq2); ++ txp = auto_cal_timing( 8, frq2); ++ if (txp == 0) { ++ txp = 1; ++ twtr = 2; ++ } ++ else { ++ twtr = txp; ++ if (txp < 2) { ++ txp = 2; ++ twtr = 2; ++ } ++ } ++ twr = auto_cal_timing( 15, frq2); ++ if (twr < 2) twr = 2; ++ trp = auto_cal_timing( 17, frq2); ++ tras = auto_cal_timing( 42, frq2); ++ trefi = auto_cal_timing(3900, frq2) / 32; ++ trfc = auto_cal_timing( 210, frq2); ++ } ++ else if (type == 7) { ++ // LPDDR3 ++ tfaw = auto_cal_timing( 50, frq2); ++ if (tfaw < 4) tfaw = 4; ++ trrd = auto_cal_timing( 10, frq2); ++ if (trrd == 0) trrd = 1; ++ trcd = auto_cal_timing( 24, frq2); ++ if (trcd < 2) trcd = 2; ++ trc = auto_cal_timing( 70, frq2); ++ twtr = auto_cal_timing( 8, frq2); ++ if (twtr < 2) twtr = 2; ++ twr = auto_cal_timing( 15, frq2); ++ if (twr < 2) twr = 2; ++ trp = auto_cal_timing( 17, frq2); ++ tras = auto_cal_timing( 42, frq2); ++ trefi = auto_cal_timing(3900, frq2) / 32; ++ trfc = auto_cal_timing( 210, frq2); ++ txp = twtr; ++ } ++ else { ++ // default ++ trfc = 128; ++ trp = 6; ++ trefi = 98; ++ txp = 10; ++ twr = 8; ++ twtr = 3; ++ tras = 14; ++ tfaw = 16; ++ trc = 20; ++ trcd = 6; ++ trrd = 3; ++ } ++ //assign the value back to the DRAM structure ++ tccd = 2; ++ trtp = 4; // not in .S ? ++ para->dram_tpr0 = (trc<<0) | (trcd<<6) | (trrd<<11) | (tfaw<<15) | (tccd<<21); ++ para->dram_tpr1 = (tras<<0) | (trp<<6) | (twr<<11) | (trtp<<15) | (twtr<<20) | (txp<<23); ++ para->dram_tpr2 = (trefi<<0) | (trfc<<12); ++ } ++ ++ unsigned int tcksrx; // t1 ++ unsigned int tckesr; // t4; ++ unsigned int trd2wr; // t6 ++ unsigned int trasmax; // t3; ++ unsigned int twtp; // s6 (was twr!) ++ unsigned int tcke; // s8 ++ unsigned int tmod; // t0 ++ unsigned int tmrd; // t5 ++ unsigned int tmrw; // a1 ++ unsigned int t_rdata_en;// a4 (was tcwl!) ++ unsigned int tcl; // a0 ++ unsigned int wr_latency;// a7 ++ unsigned int tcwl; // first a4, then a5 ++ unsigned int mr3; // s0 ++ unsigned int mr2; // t2 ++ unsigned int mr1; // s1 ++ unsigned int mr0; // a3 ++ unsigned int dmr3; // 72(sp) ++ //unsigned int trtp; // 64(sp) ++ unsigned int dmr1; // 56(sp) ++ unsigned int twr2rd; // 48(sp) ++ unsigned int tdinit3; // 40(sp) ++ unsigned int tdinit2; // 32(sp) ++ unsigned int tdinit1; // 24(sp) ++ unsigned int tdinit0; // 16(sp) ++ ++ dmr1 = para->dram_mr1; ++ dmr3 = para->dram_mr3; ++ ++ switch (type) { ++ ++ case 2: // DDR2 ++ { ++ trasmax = freq / 30; ++ if (freq < 409) { ++ tcl = 3; ++ t_rdata_en = 1; ++ mr0 = 0x06a3; ++ } ++ else { ++ t_rdata_en = 2; ++ tcl = 4; ++ mr0 = 0x0e73; ++ } ++ tmrd = 2; ++ twtp = twr + 5; ++ tcksrx = 5; ++ tckesr = 4; ++ trd2wr = 4; ++ tcke = 3; ++ tmod = 12; ++ wr_latency = 1; ++ mr3 = 0; ++ mr2 = 0; ++ tdinit0 = 200*freq + 1; ++ tdinit1 = 100*freq / 1000 + 1; ++ tdinit2 = 200*freq + 1; ++ tdinit3 = 1*freq + 1; ++ tmrw = 0; ++ twr2rd = twtr + 5; ++ tcwl = 0; ++ mr1 = dmr1; ++ break; ++ } ++ ++ case 3: // DDR3 ++ { ++ trasmax = freq / 30; ++ if (freq <= 800) { ++ mr0 = 0x1c70; ++ tcl = 6; ++ wr_latency = 2; ++ tcwl = 4; ++ mr2 = 24; ++ } ++ else { ++ mr0 = 0x1e14; ++ tcl = 7; ++ wr_latency = 3; ++ tcwl = 5; ++ mr2 = 32; ++ } ++ ++ twtp = tcwl + 2 + twtr; // WL+BL/2+tWTR ++ trd2wr = tcwl + 2 + twr; // WL+BL/2+tWR ++ twr2rd = tcwl + twtr; // WL+tWTR ++ ++ tdinit0 = 500*freq + 1; // 500 us ++ tdinit1 = 360*freq / 1000 + 1; // 360 ns ++ tdinit2 = 200*freq + 1; // 200 us ++ tdinit3 = 1*freq + 1; // 1 us ++ ++ if (((tpr13>>2) & 0x03) == 0x01 || freq < 912) { ++ mr1 = dmr1; ++ t_rdata_en = tcwl; // a5 <- a4 ++ tcksrx = 5; ++ tckesr = 4; ++ trd2wr = 5; ++ } ++ else { ++ mr1 = dmr1; ++ t_rdata_en = tcwl; // a5 <- a4 ++ tcksrx = 5; ++ tckesr = 4; ++ trd2wr = 6; ++ } ++ tcke = 3; // not in .S ? ++ tmod = 12; ++ tmrd = 4; ++ tmrw = 0; ++ mr3 = 0; ++ break; ++ } ++ ++ case 6: // LPDDR2 ++ { ++ trasmax = freq / 60; ++ mr3 = dmr3; ++ twtp = twr + 5; ++ mr2 = 6; ++ mr1 = 5; ++ tcksrx = 5; ++ tckesr = 5; ++ trd2wr = 10; ++ tcke = 2; ++ tmod = 5; ++ tmrd = 5; ++ tmrw = 3; ++ tcl = 4; ++ wr_latency = 1; ++ t_rdata_en = 1; ++ tdinit0 = 200*freq + 1; ++ tdinit1 = 100*freq / 1000 + 1; ++ tdinit2 = 11*freq + 1; ++ tdinit3 = 1*freq + 1; ++ twr2rd = twtr + 5; ++ tcwl = 2; ++ mr1 = 195; ++ mr0 = 0; ++ break; ++ } ++ ++ case 7: // LPDDR3 ++ { ++ trasmax = freq / 60; ++ if (freq < 800) { ++ tcwl = 4; ++ wr_latency = 3; ++ t_rdata_en = 6; ++ mr2 = 12; ++ } ++ else { ++ tcwl = 3; ++ tcke = 6; ++ wr_latency = 2; ++ t_rdata_en = 5; ++ mr2 = 10; ++ } ++ twtp = tcwl + 5; ++ tcl = 7; ++ mr3 = dmr3; ++ tcksrx = 5; ++ tckesr = 5; ++ trd2wr = 13; ++ tcke = 3; ++ tmod = 12; ++ tdinit0 = 400*freq + 1; ++ tdinit1 = 500*freq / 1000 + 1; ++ tdinit2 = 11*freq + 1; ++ tdinit3 = 1*freq + 1; ++ tmrd = 5; ++ tmrw = 5; ++ twr2rd = tcwl + twtr + 5; ++ mr1 = 195; ++ mr0 = 0; ++ break; ++ } ++ ++ default: ++ twr2rd = 8; // 48(sp) ++ tcksrx = 4; // t1 ++ tckesr = 3; // t4 ++ trd2wr = 4; // t6 ++ trasmax = 27; // t3 ++ twtp = 12; // s6 ++ tcke = 2; // s8 ++ tmod = 6; // t0 ++ tmrd = 2; // t5 ++ tmrw = 0; // a1 ++ tcwl = 3; // a5 ++ tcl = 3; // a0 ++ wr_latency = 1; // a7 ++ t_rdata_en = 1; // a4 ++ mr3 = 0; // s0 ++ mr2 = 0; // t2 ++ mr1 = 0; // s1 ++ mr0 = 0; // a3 ++ tdinit3 = 0; // 40(sp) ++ tdinit2 = 0; // 32(sp) ++ tdinit1 = 0; // 24(sp) ++ tdinit0 = 0; // 16(sp) ++ break; ++ } ++ if (trtp < tcl - trp + 2) { ++ trtp = tcl - trp + 2; ++ } ++ trtp = 4; ++ ++ // Update mode block when permitted ++ if ((para->dram_mr0 & 0xffff0000) == 0) para->dram_mr0 = mr0; ++ if ((para->dram_mr1 & 0xffff0000) == 0) para->dram_mr1 = mr1; ++ if ((para->dram_mr2 & 0xffff0000) == 0) para->dram_mr2 = mr2; ++ if ((para->dram_mr3 & 0xffff0000) == 0) para->dram_mr3 = mr3; ++ ++ // Set mode registers ++ writel(0x3103030, para->dram_mr0); ++ writel(0x3103034, para->dram_mr1); ++ writel(0x3103038, para->dram_mr2); ++ writel(0x310303c, para->dram_mr3); ++ writel(0x310302c, (para->dram_odt_en >> 4) & 0x3); // ?? ++ ++ // Set dram timing DRAMTMG0 - DRAMTMG5 ++ reg_val= (twtp<<24) | (tfaw<<16) | (trasmax<<8) | (tras<<0); ++ writel(0x3103058, reg_val); ++ reg_val= (txp<<16) | (trtp<<8) | (trc<<0); ++ writel(0x310305c, reg_val); ++ reg_val= (tcwl<<24) | (tcl<<16) | (trd2wr<<8) | (twr2rd<<0); ++ writel(0x3103060, reg_val); ++ reg_val= (tmrw<<16) | (tmrd<<12) | (tmod<<0); ++ writel(0x3103064, reg_val); ++ reg_val= (trcd<<24) | (tccd<<16) | (trrd<<8) | (trp<<0); ++ writel(0x3103068, reg_val); ++ reg_val= (tcksrx<<24) | (tcksrx<<16) | (tckesr<<8) | (tcke<<0); ++ writel(0x310306c, reg_val); ++ ++ // Set two rank timing ++ reg_val = readl(0x3103078); ++ reg_val &= 0x0fff0000; ++ reg_val |= (para->dram_clk < 800) ? 0xf0006600 : 0xf0007600; ++ reg_val |= 0x10; ++ writel(0x3103078, reg_val); ++ ++ // Set phy interface time PITMG0, PTR3, PTR4 ++ reg_val = (0x2<<24) | (t_rdata_en<<16) | (0x1<<8) | (wr_latency<<0); ++ writel(0x3103080, reg_val); ++ writel(0x3103050, ((tdinit0<<0)|(tdinit1<<20))); ++ writel(0x3103054, ((tdinit2<<0)|(tdinit3<<20))); ++ ++ // Set refresh timing and mode ++ reg_val = (trefi<<16) | (trfc<<0); ++ writel(0x3103090, reg_val); ++ reg_val = 0x0fff0000 & (trefi<<15); ++ writel(0x3103094, reg_val); ++} ++ ++// Not used ? ++// ++void ccm_get_sscg(void) ++{ ++ // NOTE: function is present in the assembly, but was not translated. ++} ++ ++// Not used ? ++// ++void ccm_set_pll_sscg(void) ++{ ++ // NOTE: function is present in the assembly, but was not translated. ++} ++ ++// Purpose of this routine seems to be to initialize the PLL driving ++// the MBUS and sdram. ++// ++int ccm_set_pll_ddr_clk(int index, struct dram_para_t *para) ++{ ++ unsigned int val, clk, n; ++ ++ clk = (para->dram_tpr13 & (1 << 6)) ? para->dram_tpr9 ++ : para->dram_clk; ++ ++ // set VCO clock divider ++ n = (clk * 2) / 24; ++ val = readl(0x2001010); ++ val &= 0xfff800fc; // clear dividers ++ val |= (n - 1) << 8; // set PLL division ++ val |= 0xc0000000; // enable PLL and LDO ++ writel(0x2001010, val); ++ ++ // Restart PLL locking ++ val &= 0xdfffffff; // disbable lock ++ val |= 0xc0000000; // enable PLL and LDO ++ writel(0x2001010, val); ++ val |= 0xe0000000; // re-enable lock ++ writel(0x2001010, val); ++ ++ // wait for PLL to lock ++ while ((readl(0x2001010) & 0x10000000) == 0) {;} ++ ++ udelay(20); ++ ++ // enable PLL output ++ val = readl(0x2001000); ++ val |= 0x08000000; ++ writel(0x2001000, val); ++ ++ // turn clock gate on ++ val = readl(0x2001800); ++ val &= 0xfcfffcfc; // select DDR clk source, n=1, m=1 ++ val |= 0x80000000; // turn clock on ++ writel(0x2001800, val); ++ ++ return n * 24; ++} ++ ++// Main purpose of sys_init seems to be to initalise the clocks for ++// the sdram controller. ++// ++void mctl_sys_init(struct dram_para_t *para) ++{ ++ unsigned int val; ++ ++ // s1 = 0x02001000 ++ ++ // assert MBUS reset ++ val = readl(0x2001540); ++ val &= 0xbfffffff; ++ writel(0x2001540, val); ++ ++ // turn off sdram clock gate, assert sdram reset ++ val = readl(0x200180c); ++ val &= 0xfffffffe; ++ writel(0x200180c, val); ++ val &= 0xfffefffe; ++ writel(0x200180c, val); ++ ++ // turn of bit 30 [??] ++ val = readl(0x2001800); ++ writel(0x2001800, val & 0xbfffffff); ++ // and toggle dram clock gating off + trigger update ++ val &= 0x7fffffff; ++ writel(0x2001800, val); ++ val |= 0x08000000; ++ writel(0x2001800, val); ++ udelay(10); ++ ++ // set ddr pll clock ++ val = ccm_set_pll_ddr_clk(0, para); ++ para->dram_clk = val >> 1; ++ udelay(100); ++ dram_disable_all_master(); ++ ++ // release sdram reset ++ val = readl(0x200180c); ++ val |= 0x00010000; ++ writel(0x200180c, val); ++ ++ // release MBUS reset ++ val = readl(0x2001540); ++ val |= 0x40000000; ++ writel(0x2001540, val); ++ ++ // turn bit 30 back on [?] ++ val = readl(0x2001800); ++ val |= 0x40000000; ++ writel(0x2001800, val); ++ udelay(5); ++ ++ // turn on sdram clock gate ++ val = readl(0x200180c); ++ val |= 0x0000001; // (1<<0) ++ writel(0x200180c, val); ++ ++ // turn dram clock gate on, trigger sdr clock update ++ val = readl(0x2001800); ++ val |= 0x80000000; ++ writel(0x2001800, val); ++ val |= 0x88000000; ++ writel(0x2001800, val); ++ udelay(5); ++ ++ // mCTL clock enable ++ writel(0x310300c, 0x00008000); ++ udelay(10); ++} ++ ++// The main purpose of this routine seems to be to copy an address configuration ++// from the dram_para1 and dram_para2 fields to the PHY configuration registers ++// (0x3102000, 0x3102004). ++// ++void mctl_com_init(struct dram_para_t *para) ++{ ++ unsigned int val, end, ptr; ++ int i; ++ ++ // purpose ?? ++ val = readl(0x3102008) & 0xffffc0ff; ++ val |= 0x2000; ++ writel(0x3102008, val); ++ ++ // Set sdram type and word width ++ val = readl(0x3102000) & 0xff000fff; ++ val |= (para->dram_type &0x7) << 16; // DRAM type ++ val |= (~para->dram_para2 & 0x1) << 12; // DQ width ++ if((para->dram_type) != 6 && (para->dram_type) != 7) { ++ val |= ((para->dram_tpr13 >> 5) & 0x1) << 19; // 2T or 1T ++ val |= 0x400000; ++ } ++ else { ++ val |= 0x480000; // type 6 and 7 must use 1T ++ } ++ writel(0x3102000, val); ++ ++ // init rank / bank / row for single/dual or two different ranks ++ val = para->dram_para2; ++ end = ((val & 0x100) && (((val >> 12) & 0xf) != 1)) ? 32 : 16; ++ ptr = 0x3102000; ++ ++ for (i = 0 ; i != end; i += 16) { ++ ++ val = readl(ptr) & 0xfffff000; ++ ++ val |= (para->dram_para2 >> 12) & 0x3; // rank ++ val |= ((para->dram_para1 >> (i + 12)) << 2) & 0x4; // bank - 2 ++ val |= (((para->dram_para1 >> (i + 4)) - 1) << 4) & 0xff; // row - 1 ++ ++ // convert from page size to column addr width - 3 ++ switch ((para->dram_para1 >> i) & 0xf) { ++ case 8: val |= 0xa00; break; ++ case 4: val |= 0x900; break; ++ case 2: val |= 0x800; break; ++ case 1: val |= 0x700; break; ++ default: val |= 0x600; break; ++ } ++ writel(ptr, val); ++ ptr += 4; ++ } ++ ++ // set ODTMAP based on number of ranks in use ++ val = (readl(0x3102000) & 0x1) ? 0x303 : 0x201; ++ writel(0x3103120, val); ++ ++ // set mctl reg 3c4 to zero when using half DQ ++ if (para->dram_para2 & (1 << 0)) { ++ writel(0x31033c4, 0); ++ } ++ ++ // purpose ?? ++ if (para->dram_tpr4) { ++ val = readl(0x3102000); ++ val |= (para->dram_tpr4 << 25) & 0x06000000; ++ writel(0x3102000, val); ++ ++ val = readl(0x3102004); ++ val |= ((para->dram_tpr4 >> 2) << 12) & 0x001ff000; ++ writel(0x3102004, val); ++ } ++} ++ ++// This routine seems to have several remapping tables for 22 lines. ++// It is unclear which lines are being remapped. It seems to pick ++// table cfg7 for the Nezha board. ++// ++void mctl_phy_ac_remapping(struct dram_para_t *para) ++{ ++ char cfg0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++ static char cfg1[] = { 1, 9, 3, 7, 8, 18, 4, 13, 5, 6, 10, ++ 2, 14, 12, 0, 0, 21, 17, 20, 19, 11, 22 }; ++ static char cfg2[] = { 4, 9, 3, 7, 8, 18, 1, 13, 2, 6, 10, ++ 5, 14, 12, 0, 0, 21, 17, 20, 19, 11, 22 }; ++ static char cfg3[] = { 1, 7, 8, 12, 10, 18, 4, 13, 5, 6, 3, ++ 2, 9, 0, 0, 0, 21, 17, 20, 19, 11, 22 }; ++ static char cfg4[] = { 4, 12, 10, 7, 8, 18, 1, 13, 2, 6, 3, ++ 5, 9, 0, 0, 0, 21, 17, 20, 19, 11, 22 }; ++ static char cfg5[] = { 13, 2, 7, 9, 12, 19, 5, 1, 6, 3, 4, ++ 8, 10, 0, 0, 0, 21, 22, 18, 17, 11, 20 }; ++ static char cfg6[] = { 3, 10, 7, 13, 9, 11, 1, 2, 4, 6, 8, ++ 5, 12, 0, 0, 0, 20, 1, 0, 21, 22, 17 }; ++ static char cfg7[] = { 3, 2, 4, 7, 9, 1, 17, 12, 18, 14, 13, ++ 8, 15, 6, 10, 5, 19, 22, 16, 21, 20, 11 }; ++ ++ unsigned int fuse, val; ++ ++ // read SID info @ 0x228 ++ fuse = (readl(0x3002228) >> 8) & 0x4; ++ printf("ddr_efuse_type: 0x%x\n", fuse); ++ ++ if ((para->dram_tpr13 >> 18) & 0x3) { ++ memcpy_self(cfg0, cfg7, 22); ++ } ++ else { ++ switch (fuse) { ++ case 8: memcpy_self(cfg0, cfg2, 22); break; ++ case 9: memcpy_self(cfg0, cfg3, 22); break; ++ case 10: memcpy_self(cfg0, cfg5, 22); break; ++ case 11: memcpy_self(cfg0, cfg4, 22); break; ++ default: ++ case 12: memcpy_self(cfg0, cfg1, 22); break; ++ case 13: ++ case 14: break; ++ } ++ } ++ if (para->dram_type == 2) { ++ if (fuse == 15) return; ++ memcpy_self(cfg0, cfg6, 22); ++ } ++ if ( para->dram_type == 2 || para->dram_type == 3) { ++ ++ val = (cfg0[ 4] << 25) | (cfg0[ 3] << 20) | (cfg0[ 2] << 15) | ++ (cfg0[ 1] << 10) | (cfg0[ 0] << 5); ++ writel(0x3102500, val); ++ ++ val = (cfg0[10] << 25) | (cfg0[ 9] << 20) | (cfg0[ 8] << 15) | ++ (cfg0[ 7] << 10) | (cfg0[ 6] << 5) | cfg0[ 5]; ++ writel(0x3102504, val); ++ ++ val = (cfg0[15] << 20) | (cfg0[14] << 15) | ++ (cfg0[13] << 10) | (cfg0[12] << 5) | cfg0[11]; ++ writel(0x3102508, val); ++ ++ val = (cfg0[21] << 25) | (cfg0[20] << 20) | (cfg0[19] << 15) | ++ (cfg0[18] << 10) | (cfg0[17] << 5) | cfg0[16]; ++ writel(0x310250c, val); ++ ++ val = (cfg0[ 4] << 25) | (cfg0 [3] << 20) | (cfg0[2] << 15) | ++ (cfg0[ 1] << 10) | (cfg0 [0] << 5) | 1; ++ writel(0x3102500, val); ++ } ++} ++ ++// Init the controller channel. The key part is placing commands in the main ++// command register (PIR, 0x3103000) and checking command status (PGSR0, 0x3103010). ++// ++unsigned int mctl_channel_init(unsigned int ch_index, struct dram_para_t *para) ++{ ++ unsigned int val, dqs_gating_mode; ++ ++ dqs_gating_mode = (para->dram_tpr13 >> 2) & 0x3; ++ ++ // set DDR clock to half of CPU clock ++ val = readl(0x310200c) & 0xfffff000; ++ val |= (para->dram_clk >> 1 ) - 1; ++ writel(0x310200c, val); ++ ++ // MRCTRL0 nibble 3 undocumented ++ val = readl(0x3103108) & 0xfffff0ff; ++ val |= 0x300; ++ writel(0x3103108, val); ++ ++ // DX0GCR0 ++ val = readl(0x3103344) & 0xffffffcf; ++ val |= ((~para->dram_odt_en) << 5) & 0x20; ++ if (para->dram_clk > 672) { ++ val &= 0xffff09f1; ++ val |= 0x00000400; ++ } ++ else { ++ val &= 0xffff0ff1; ++ } ++ writel(0x3103344, val); ++ ++ // DX1GCR0 ++ val = readl(0x31033c4) & 0xffffffcf; ++ val |= ((~para->dram_odt_en) << 5) & 0x20; ++ if (para->dram_clk > 672) { ++ val &= 0xffff09f1; ++ val |= 0x00000400; ++ } ++ else { ++ val &= 0xffff0ff1; ++ } ++ writel(0x31033c4, val); ++ ++ // 0x3103208 undocumented ++ val = readl(0x3103208); ++ val |= 0x2; ++ writel(0x3103208, val); ++ ++ eye_delay_compensation(para); ++ ++ //set PLL SSCG ? ++ // ++ val = readl(0x3103108); ++ if (dqs_gating_mode == 1) { ++ ++ val &= ~(0xc0); ++ writel(0x3103108, val); ++ ++ val = readl(0x31030bc); ++ val &= 0xfffffef8; ++ writel(0x31030bc, val); ++ } ++ else if (dqs_gating_mode == 2) { ++ ++ val &= ~(0xc0); ++ val |= 0x80; ++ writel(0x3103108, val); ++ ++ val = readl(0x31030bc); ++ val &= 0xfffffef8; ++ val |= ((para->dram_tpr13 >> 16) & 0x1f) - 2; ++ val |= 0x100; ++ writel(0x31030bc, val); ++ ++ val = readl(0x310311c) & 0x7fffffff; ++ val |= 0x08000000; ++ writel(0x310311c, val); ++ } ++ else { ++ val &= ~(0x40); ++ writel(0x3103108, val); ++ ++ udelay(10); ++ ++ val = readl(0x3103108); ++ val |= 0xc0; ++ writel(0x3103108, val); ++ } ++ ++ if (para->dram_type == 6 || para->dram_type == 7) { ++ val = readl(0x310311c); ++ if (dqs_gating_mode == 1) { ++ val &= 0xf7ffff3f; ++ val |= 0x80000000; ++ } ++ else { ++ val &= 0x88ffffff; ++ val |= 0x22000000; ++ } ++ writel(0x310311c, val); ++ } ++ ++ val = readl(0x31030c0); ++ val &= 0xf0000000; ++ val |= (para->dram_para2 & (1 << 12)) ? 0x03000001 : 0x01000007; // 0x01003087 XXX ++ writel(0x31030c0, val); ++ ++ if (readl(0x70005d4) & (1 << 16)) { ++ val = readl(0x7010250); ++ val &= 0xfffffffd; ++ writel(0x7010250, val); ++ ++ udelay(10); ++ } ++ ++ // Set ZQ config ++ val = readl(0x3103140) & 0xfc000000; ++ val |= para->dram_zq & 0x00ffffff; ++ val |= 0x02000000; ++ writel(0x3103140, val); ++ ++ // Initialise DRAM controller ++ if (dqs_gating_mode == 1) { ++ writel(0x3103000, 0x52); // prep PHY reset + PLL init + z-cal ++ writel(0x3103000, 0x53); // Go ++ ++ while ((readl(0x3103010) & 0x1) == 0) {;} // wait for IDONE ++ udelay(10); ++ ++ // 0x520 = prep DQS gating + DRAM init + d-cal ++ val = (para->dram_type == 3) ? 0x5a0 // + DRAM reset ++ : 0x520; ++ } ++ else { ++ if ((readl(0x70005d4) & (1 << 16)) == 0) { ++ // prep DRAM init + PHY reset + d-cal + PLL init + z-cal ++ val = (para->dram_type == 3) ? 0x1f2 // + DRAM reset ++ : 0x172; ++ } ++ else { ++ // prep PHY reset + d-cal + z-cal ++ val = 0x62; ++ } ++ } ++ ++ writel(0x3103000, val); // Prep ++ val |= 1; ++ writel(0x3103000, val); // Go ++ ++ udelay(10); ++ while ((readl(0x3103010) & 0x1) == 0) {;} // wait for IDONE ++ ++ if (readl(0x70005d4) & (1 << 16)) { ++ ++ val = readl(0x310310c); ++ val &= 0xf9ffffff; ++ val |= 0x04000000; ++ writel(0x310310c, val); ++ ++ udelay(10); ++ ++ val = readl(0x3103004); ++ val |= 0x1; ++ writel(0x3103004, val); ++ ++ while ((readl(0x3103018) & 0x7) != 0x3) {;} ++ ++ val = readl(0x7010250); ++ val &= 0xfffffffe; ++ writel(0x7010250, val); ++ ++ udelay(10); ++ ++ val = readl(0x3103004); ++ val &= 0xfffffffe; ++ writel(0x3103004, val); ++ ++ while ((readl(0x3103018) & 0x7) != 0x1) {;} ++ ++ udelay(15); ++ ++ if (dqs_gating_mode == 1) { ++ ++ val = readl(0x3103108); ++ val &= 0xffffff3f; ++ writel(0x3103108, val); ++ ++ val = readl(0x310310c); ++ val &= 0xf9ffffff; ++ val |= 0x02000000; ++ writel(0x310310c, val); ++ ++ udelay(1); ++ writel(0x3103000, 0x401); ++ ++ while ((readl(0x3103010) & 0x1) == 0) {;} ++ } ++ } ++ ++ // Check for training error ++ val = readl(0x3103010); ++ if (((val >> 20) & 0xff) && (val & 0x100000)) { ++ printf("ZQ calibration error, check external 240 ohm resistor.\n"); ++ return 0; ++ } ++ ++ // STATR = Zynq STAT? Wait for status 'normal'? ++ while ((readl(0x3103018) & 0x1) == 0) {;} ++ ++ val = readl(0x310308c); ++ val |= 0x80000000; ++ writel(0x310308c, val); ++ ++ udelay(10); ++ ++ val = readl(0x310308c); ++ val &= 0x7fffffff; ++ writel(0x310308c, val); ++ ++ udelay(10); ++ ++ val = readl(0x3102014); ++ val |= 0x80000000; ++ writel(0x3102014, val); ++ ++ udelay(10); ++ ++ val = readl(0x310310c); ++ val &= 0xf9ffffff; ++ writel(0x310310c, val); ++ ++ if (dqs_gating_mode == 1) { ++ val = readl(0x310311c); ++ val &= 0xffffff3f; ++ val |= 0x00000040; ++ writel(0x310311c, val); ++ } ++ return 1; ++} ++ ++// The below routine reads the dram config registers and extracts ++// the number of address bits in each rank available. It then calculates ++// total memory size in MB. ++// ++int DRAMC_get_dram_size(void) ++{ ++ unsigned int rval, temp, size0, size1; ++ ++ rval = readl(0x3102000); // MC_WORK_MODE0 ++ ++ temp = (rval>>8) & 0xf; // page size - 3 ++ temp += (rval>>4) & 0xf; // row width - 1 ++ temp += (rval>>2) & 0x3; // bank count - 2 ++ temp -= 14; // 1MB = 20 bits, minus above 6 = 14 ++ size0 = 1 << temp; ++ ++ temp = rval & 0x3; // rank count = 0? -> done ++ if (temp == 0) { ++ return size0; ++ } ++ ++ rval = readl(0x3102004); // MC_WORK_MODE1 ++ ++ temp = rval & 0x3; ++ if (temp == 0) { // two identical ranks ++ return 2 * size0; ++ } ++ ++ temp = (rval>>8) & 0xf; // page size - 3 ++ temp += (rval>>4) & 0xf; // row width - 1 ++ temp += (rval>>2) & 0x3; // bank number - 2 ++ temp -= 14; // 1MB = 20 bits, minus above 6 = 14 ++ size1 = 1 << temp; ++ ++ return size0 + size1; // add size of each rank ++} ++ ++// The below routine reads the command status register to extract ++// DQ width and rank count. This follows the DQS training command in ++// channel_init. If error bit 22 is reset, we have two ranks and full DQ. ++// If there was an error, figure out whether it was half DQ, single rank, ++// or both. Set bit 12 and 0 in dram_para2 with the results. ++// ++int dqs_gate_detect(struct dram_para_t *para) ++{ ++ unsigned int rval, dx0, dx1; ++ ++ if (readl(0x3103010) & (1 << 22)) { ++ ++ dx0 = (readl(0x3103348) >> 24) & 0x3; ++ dx1 = (readl(0x31033c8) >> 24) & 0x3; ++ ++ if (dx0 == 2) { ++ rval = para->dram_para2; ++ rval &= 0xffff0ff0; ++ if (dx0 != dx1) { ++ rval |= 0x1; ++ para->dram_para2 = rval; ++ printf("[AUTO DEBUG] single rank and half DQ!\n"); ++ return 1; ++ } ++ para->dram_para2 = rval; ++ printf("[AUTO DEBUG] single rank and full DQ!\n"); ++ return 1; ++ } ++ else if (dx0 == 0) { ++ rval = para->dram_para2; ++ rval &= 0xfffffff0; ++ rval |= 0x00001001; ++ para->dram_para2 = rval; ++ printf("[AUTO DEBUG] dual rank and half DQ!\n"); ++ return 1; ++ } ++ else { ++ if (para->dram_tpr13 & (1 << 29)) { ++ printf("DX0 state:%d\n", dx0); ++ printf("DX1 state:%d\n", dx1); ++ } ++ return 0; ++ } ++ } ++ else { ++ rval = para->dram_para2; ++ rval &= 0xfffffff0; ++ rval |= 0x00001000; ++ para->dram_para2 = rval; ++ printf("[AUTO DEBUG] two rank and full DQ!\n"); ++ return 1; ++ } ++} ++ ++ ++#define SDRAM_BASE ((unsigned int *)0x40000000) ++#define uint unsigned int ++ ++int dramc_simple_wr_test(uint mem_mb, int len) ++{ ++ unsigned int offs = (mem_mb >> 1) << 18; // half of memory size ++ unsigned int patt1 = 0x01234567; ++ unsigned int patt2 = 0xfedcba98; ++ unsigned int *addr, v1, v2, i; ++ ++ addr = SDRAM_BASE; ++ for (i = 0; i != len; i++, addr++) { ++ writel(addr, patt1 + i); ++ writel(addr + offs, patt2 + i); ++ } ++ ++ addr = SDRAM_BASE; ++ for (i = 0; i != len; i++) { ++ v1 = readl(addr+i); ++ v2 = patt1 + i; ++ if (v1 != v2) { ++ printf("DRAM simple test FAIL.\n"); ++ printf("%x != %x at address %p\n", v1, v2, addr+i); ++ return 1; ++ } ++ v1 = readl(addr+offs+i); ++ v2 = patt2 + i; ++ if (v1 != v2) { ++ printf("DRAM simple test FAIL.\n"); ++ printf("%x != %x at address %p\n", v1, v2, addr+offs+i); ++ return 1; ++ } ++ } ++ printf("DRAM simple test OK.\n"); ++ return 0; ++} ++ ++// Set the Vref mode for the controller ++// ++void mctl_vrefzq_init(struct dram_para_t *para) ++{ ++ unsigned int val; ++ ++ if ((para->dram_tpr13 & (1 << 17)) == 0) { ++ val = readl(0x3103110) & 0x80808080; // IOCVR0 ++ val |= para->dram_tpr5; ++ writel(0x3103110, val); ++ ++ if ((para->dram_tpr13 & (1 << 16)) == 0) { ++ val = readl(0x3103114) & 0xffffff80; // IOCVR1 ++ val |= para->dram_tpr6 & 0x7f; ++ writel(0x3103114, val); ++ } ++ } ++} ++ ++// Perform an init of the controller. This is actually done 3 times. The first ++// time to establish the number of ranks and DQ width. The second time to ++// establish the actual ram size. The third time is final one, with the final ++// settings. ++// ++int mctl_core_init(struct dram_para_t *para) ++{ ++ mctl_sys_init(para); ++ mctl_vrefzq_init(para); ++ mctl_com_init(para); ++ mctl_phy_ac_remapping(para); ++ auto_set_timing_para(para); ++ return mctl_channel_init(0, para); ++} ++ ++ ++#define RAM_BASE (0x40000000) ++ ++// Autoscan sizes a dram device by cycling through address lines and figuring ++// out if it is connected to a real address line, or if the address is a mirror. ++// First the column and bank bit allocations are set to low values (2 and 9 address ++// lines. Then a maximum allocation (16 lines) is set for rows and this is tested. ++// Next the BA2 line is checked. This seems to be placed above the column, BA0-1 and ++// row addresses. Finally, the column address is allocated 13 lines and these are ++// tested. The results are placed in dram_para1 and dram_para2. ++// ++int auto_scan_dram_size(struct dram_para_t *para) // s7 ++{ ++ unsigned int rval, i, j, rank, maxrank, offs, mc_work_mode; ++ unsigned int chk, ptr, shft, banks; ++ ++ if (mctl_core_init(para) == 0) { ++ printf("[ERROR DEBUG] DRAM initialisation error : 0!\n"); ++ return 0; ++ } ++ ++ maxrank = (para->dram_para2 & 0xf000) ? 2 : 1; ++ mc_work_mode = 0x3102000; ++ offs = 0; ++ ++ // write test pattern ++ for (i = 0, ptr = RAM_BASE; i < 64; i++, ptr += 4) { ++ writel(ptr, (i & 1) ? ptr : ~ptr); ++ } ++ ++ for (rank = 0; rank < maxrank; ) { ++ ++ // Set row mode ++ rval = readl(mc_work_mode); ++ rval &= 0xfffff0f3; ++ rval |= 0x000006f0; ++ writel(mc_work_mode, rval); ++ while (readl(mc_work_mode) != rval); ++ ++ // Scan per address line, until address wraps (i.e. see shadow) ++ for(i = 11; i < 17; i++) { ++ chk = RAM_BASE + (1 << (i + 11)); ++ ptr = RAM_BASE; ++ for (j = 0; j < 64; j++) { ++ if (readl(chk) != ((j & 1) ? ptr : ~ptr)) ++ goto out1; ++ ptr += 4; ++ chk += 4; ++ } ++ break; ++ out1: ; ++ } ++ if (i > 16) i = 16; ++ printf("[AUTO DEBUG] rank %d row = %d\n", rank, i); ++ ++ // Store rows in para 1 ++ shft = 4 + offs; ++ rval = para->dram_para1; ++ rval &= ~(0xff << shft); ++ rval |= i << shft; ++ para->dram_para1 = rval; ++ ++ if (rank == 1) { ++ // Set bank mode for rank0 ++ rval = readl(0x3102000); ++ rval &= 0xfffff003; ++ rval |= 0x000006a4; ++ writel(0x3102000, rval); ++ } ++ ++ // Set bank mode for current rank ++ rval = readl(mc_work_mode); ++ rval &= 0xfffff003; ++ rval |= 0x000006a4; ++ writel(mc_work_mode, rval); ++ while (readl(mc_work_mode) != rval); ++ ++ // Test if bit A23 is BA2 or mirror XXX A22? ++ chk = RAM_BASE + (1 << 22); ++ ptr = RAM_BASE; ++ for (i = 0, j = 0; i < 64; i++) { ++ if (readl(chk) != ((i & 1) ? ptr : ~ptr)) { ++ j = 1; ++ break; ++ } ++ ptr += 4; ++ chk += 4; ++ } ++ banks = (j + 1) << 2; // 4 or 8 ++ printf("[AUTO DEBUG] rank %d bank = %d\n", rank, banks); ++ ++ // Store banks in para 1 ++ shft = 12 + offs; ++ rval = para->dram_para1; ++ rval &= ~(0xf << shft); ++ rval |= j << shft; ++ para->dram_para1 = rval; ++ ++ if (rank == 1) { ++ // Set page mode for rank0 ++ rval = readl(0x3102000); ++ rval &= 0xfffff003; ++ rval |= 0x00000aa0; ++ writel(0x3102000, rval); ++ } ++ ++ // Set page mode for current rank ++ rval = readl(mc_work_mode); ++ rval &= 0xfffff003; ++ rval |= 0x00000aa0; ++ writel(mc_work_mode, rval); ++ while (readl(mc_work_mode) != rval); ++ ++ // Scan per address line, until address wraps (i.e. see shadow) ++ for(i = 9; i < 14; i++) { ++ chk = RAM_BASE + (1 << i); ++ ptr = RAM_BASE; ++ for (j = 0; j < 64; j++) { ++ if (readl(chk) != ((j & 1) ? ptr : ~ptr)) ++ goto out2; ++ ptr += 4; ++ chk += 4; ++ } ++ break; ++ out2:; ++ } ++ if (i > 13) i = 13; ++ int pgsize = (i==9) ? 0 : (1 << (i-10)); ++ printf("[AUTO DEBUG] rank %d page size = %d KB\n", rank, pgsize); ++ ++ // Store page size ++ shft = offs; ++ rval = para->dram_para1; ++ rval &= ~(0xf << shft); ++ rval |= pgsize << shft; ++ para->dram_para1 = rval; ++ ++ // Move to next rank ++ rank++; ++ if (rank != maxrank) { ++ if (rank == 1) { ++ rval = readl(0x3202000); // MC_WORK_MODE ++ rval &= 0xfffff003; ++ rval |= 0x000006f0; ++ writel(0x3202000, rval); ++ ++ rval = readl(0x3202004); // MC_WORK_MODE2 ++ rval &= 0xfffff003; ++ rval |= 0x000006f0; ++ writel(0x3202004, rval); ++ } ++ offs += 16; // store rank1 config in upper half of para1 ++ mc_work_mode += 4; // move to MC_WORK_MODE2 ++ } ++ } ++ if (maxrank == 2) { ++ para->dram_para2 &= 0xfffff0ff; ++ // note: rval is equal to para->dram_para1 here ++ if ((rval & 0xffff) == ((rval >> 16) & 0xffff)) { ++ printf("rank1 config same as rank0\n"); ++ } ++ else { ++ para->dram_para2 |= 0x00000100; ++ printf("rank1 config different from rank0\n"); ++ } ++ } ++ return 1; ++} ++ ++// This routine sets up parameters with dqs_gating_mode equal to 1 and two ++// ranks enabled. It then configures the core and tests for 1 or 2 ranks and ++// full or half DQ width. it then resets the parameters to the original values. ++// dram_para2 is updated with the rank & width findings. ++// ++int auto_scan_dram_rank_width(struct dram_para_t *para) ++{ ++ unsigned int s1 = para->dram_tpr13; ++ unsigned int s2 = para->dram_para1; ++ unsigned int v; ++ ++ para->dram_para1 = 0x00b000b0; ++ v = (para->dram_para2 & 0xfffffff0) | 0x1000; ++ para->dram_para2 = v; ++ ++ v = (s1 & 0xfffffff7) | 0x5; // set DQS probe mode ++ para->dram_tpr13 = v; ++ ++ mctl_core_init(para); ++ if (readl(0x3103010) & (1 << 20)) { ++ return 0; ++ } ++ if (dqs_gate_detect(para) == 0) { ++ return 0; ++ } ++ ++ para->dram_tpr13 = s1; ++ para->dram_para1 = s2; ++ return 1; ++} ++ ++// This routine determines the sdram topology. It first establishes the number ++// of ranks and the DQ width. Then it scans the sdram address lines to establish ++// the size of each rank. It then updates dram_tpr13 to reflect that the sizes ++// are now known: a re-init will not repeat the autoscan. ++// ++int auto_scan_dram_config(struct dram_para_t *para) ++{ ++ if (((para->dram_tpr13 & (1 << 14)) == 0) && ++ (auto_scan_dram_rank_width(para) == 0)) ++ { ++ printf("[ERROR DEBUG] auto scan dram rank & width failed !\n"); ++ return 0; ++ } ++ if (((para->dram_tpr13 & (1 << 0)) == 0) && ++ (auto_scan_dram_size(para) == 0 )) ++ { ++ printf("[ERROR DEBUG] auto scan dram size failed !\n"); ++ return 0; ++ } ++ if ((para->dram_tpr13 & (1 << 15)) == 0) { ++ para->dram_tpr13 |= 0x6003; ++ } ++ return 1; ++} ++ ++ ++signed int init_DRAM(int type, struct dram_para_t *para) // s0 ++{ ++ int rc, mem_size; ++ ++ // Test ZQ status ++ if (para->dram_tpr13 & (1 << 16)) { ++ printf("DRAM only have internal ZQ!!\n"); ++ writel(0x3000160, readl(0x3000160) | 0x100); ++ writel(0x3000168, 0); ++ udelay(10); ++ } ++ else { ++ writel(0x7010254, 0); ++ writel(0x3000160, readl(0x3000160) & ~0x003); ++ udelay(10); ++ writel(0x3000160, readl(0x3000160) & ~0x108); ++ udelay(10); ++ writel(0x3000160, readl(0x3000160) | 0x001); ++ udelay(20); ++ printf("ZQ value = 0x%x***********\n", readl(0x3000172)); ++ } ++ ++ // Set voltage ++ dram_vol_set(para); ++ ++ // Set SDRAM controller auto config ++ if ( (para->dram_tpr13 & 0x1)==0 ) { ++ if ( auto_scan_dram_config(para)==0 ) { ++ return 0; ++ } ++ } ++ ++ // Print header message (too late) ++ printf("DRAM BOOT DRIVE INFO: %s\n", "V0.24"); ++ printf("DRAM CLK = %d MHz\n", para->dram_clk); ++ printf("DRAM Type = %d (2:DDR2,3:DDR3)\n", para->dram_type); ++ if ( (para->dram_odt_en & 0x1) == 0 ) { ++ printf("DRAMC read ODT off.\n"); ++ } ++ else { ++ printf("DRAMC ZQ value: 0x%x\n", para->dram_zq); ++ } ++ ++ // report ODT ++ rc = para->dram_mr1; ++ if ( (rc & 0x44)==0 ) { ++ printf("DRAM ODT off.\n"); ++ } ++ else { ++ printf("DRAM ODT value: 0x%x.\n", rc); ++ } ++ ++ // Init core, final run ++ if ( mctl_core_init(para)==0 ) { ++ printf("DRAM initialisation error : 1 !\n"); ++ return 0; ++ } ++ ++ // Get sdram size ++ rc = para->dram_para2; ++ if ( rc<0 ) { ++ rc = (rc & 0x7fff0000U) >> 16; ++ } ++ else { ++ rc = DRAMC_get_dram_size(); ++ printf("DRAM SIZE =%d M\n", rc); ++ para->dram_para2 = (para->dram_para2 & 0xffffu) | rc << 16; ++ } ++ mem_size = rc; ++ ++ // Purpose ?? ++ if ( para->dram_tpr13 & (1 << 30) ) { ++ rc = readl(¶->dram_tpr8); ++ if ( rc==0 ) { ++ rc = 0x10000200; ++ } ++ writel(0x31030a0, rc); ++ writel(0x310309c, 0x40a); ++ writel(0x3103004, readl(0x3103004) | 1 ); ++ printf("Enable Auto SR"); ++ } ++ else { ++ writel(0x31030a0, readl(0x31030a0) & 0xffff0000); ++ writel(0x3103004, readl(0x3103004) & (~0x1) ); ++ } ++ ++ // Pupose ?? ++ rc = readl(0x3103100) & ~(0xf000); ++ if ( (para->dram_tpr13 & 0x200)==0 ) { ++ if ( para->dram_type != 6 ) { ++ writel(0x3103100, rc); ++ } ++ } ++ else { ++ writel(0x3103100, rc | 0x5000); ++ } ++ ++ writel(0x3103140, readl(0x3103140) | (1 << 31)); ++ if (para->dram_tpr13 & (1 << 8)) { ++ writel(0x31030b8, readl(0x3103140) | 0x300); ++ } ++ ++ rc = readl(0x3103108); ++ if (para->dram_tpr13 & (1 << 16)) { ++ rc &= 0xffffdfff; ++ } ++ else { ++ rc |= 0x00002000; ++ } ++ writel(0x3103108, rc); ++ ++ ++ // Purpose ?? ++ if (para->dram_type == 7) { ++ rc = readl(0x310307c) & 0xfff0ffff; ++ rc |= 0x0001000; ++ writel(0x310307c, rc); ++ } ++ ++ dram_enable_all_master(); ++ //if (dramc_simple_wr_test(mem_size, 64)) return 0; ++ if (para->dram_tpr13 & (1 << 28)) { ++ rc = readl(0x70005d4); ++ if ( (rc & (1 << 16)) || dramc_simple_wr_test(mem_size, 4096) ) { ++ return 0; ++ } ++ } ++ ++ return mem_size; ++} ++ ++struct sunxi_ram_priv { ++ size_t size; ++}; ++ ++static struct dram_para_t dram_para = { ++ 0x00000318, ++ 0x00000003, ++ 0x007b7bfb, ++ 0x00000001, ++ 0x000010d2, ++ 0x00000000, ++ 0x00001c70, ++ 0x00000042, ++ 0x00000018, ++ 0x00000000, ++ 0x004a2195, ++ 0x02423190, ++ 0x0008b061, ++ 0xb4787896, ++ 0x00000000, ++ 0x48484848, ++ 0x00000048, ++ 0x1620121e, ++ 0x00000000, ++ 0x00000000, ++ 0x00000000, ++ 0x00870000, ++ 0x00000024, ++ 0x34050100, ++}; ++ ++static int sunxi_ram_probe(struct udevice *dev) ++{ ++ struct sunxi_ram_priv *priv = dev_get_priv(dev); ++ int ret; ++ ++ printf("%s: %s: probing\n", __func__, dev->name); ++ ++ ret = init_DRAM(0, &dram_para); ++ if (ret <= 0) { ++ printf("DRAM init failed: %d\n", ret); ++ return ret; ++ } ++ ++ priv->size = ret * 1024 * 1024; ++ ++ return 0; ++} ++ ++static int sunxi_ram_get_info(struct udevice *dev, struct ram_info *info) ++{ ++ struct sunxi_ram_priv *priv = dev_get_priv(dev); ++ ++ printf("%s: %s: getting info\n", __func__, dev->name); ++ ++ info->base = CONFIG_SYS_SDRAM_BASE; ++ info->size = priv->size; ++ ++ return 0; ++} ++ ++static struct ram_ops sunxi_ram_ops = { ++ .get_info = sunxi_ram_get_info, ++}; ++ ++static const struct udevice_id sunxi_ram_ids[] = { ++ { .compatible = "allwinner,sun20i-d1-mbus" }, ++ { } ++}; ++ ++U_BOOT_DRIVER(sunxi_ram) = { ++ .name = "sunxi_ram", ++ .id = UCLASS_RAM, ++ .of_match = sunxi_ram_ids, ++ .ops = &sunxi_ram_ops, ++ .probe = sunxi_ram_probe, ++ .priv_auto = sizeof(struct sunxi_ram_priv), ++}; ++ ++#endif +--- /dev/null ++++ b/drivers/ram/sunxi/sdram.h +@@ -0,0 +1,46 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++/* ++ * dram_para1 bits: ++ * 16-19 = page size ++ * 20-27 = row count ++ * 28 = banks 4 or 8 ++ * ++ * dram_para2 bits: ++ * 0 = DQ width ++ * 4 = CS1 control ++ * 8-11 = rank flags? bit 8 = ranks differ in config ++ * 12-13 = rank ++ */ ++ ++/* MC_WORK_MODE bits ++ * 0- 1 = ranks code ++ * 2- 3 = banks, log2 - 2 2 3 2 ++ * 4- 7 = row width, log2 - 1 16 11 11 ++ * 8-11 = page size, log2 - 3 9 9 13 ++ * 12-15 = DQ width (or 12-14?) ++ * 16-18 = dram type (2=DDR2, 3=DDR3, 6=LPDDR2, 7=LPDDR3) ++ * 19 = 2T or 1T ++ * 23-24 = ranks code (again?) ++ */ ++ ++#define DRAM_MR0 ((void*)0x3103030) ++#define DRAM_MR1 ((void*)0x3103034) ++#define DRAM_MR2 ((void*)0x3103038) ++#define DRAM_MR3 ((void*)0x310303c) ++ ++#define DRAMTMG0 ((void*)0x3103058) ++#define DRAMTMG1 ((void*)0x310305c) ++#define DRAMTMG2 ((void*)0x3103060) ++#define DRAMTMG3 ((void*)0x3103064) ++#define DRAMTMG4 ((void*)0x3103068) ++#define DRAMTMG5 ((void*)0x310306c) ++#define DRAMTMG6 ((void*)0x3103070) ++#define DRAMTMG7 ((void*)0x3103074) ++#define DRAMTMG8 ((void*)0x3103078) ++ ++#define PITMG0 ((void*)0x3103080) ++#define PTR3 ((void*)0x3103050) ++#define PTR4 ((void*)0x3103054) ++#define RFSHTMG ((void*)0x3103090) ++#define RFSHCTL1 ((void*)0x3103094) diff --git a/package/boot/uboot-d1/patches/0084-spi-sunxi-Hack-up-the-driver-for-the-D1.patch b/package/boot/uboot-d1/patches/0084-spi-sunxi-Hack-up-the-driver-for-the-D1.patch new file mode 100644 index 00000000000000..1ce106e987909f --- /dev/null +++ b/package/boot/uboot-d1/patches/0084-spi-sunxi-Hack-up-the-driver-for-the-D1.patch @@ -0,0 +1,29 @@ +From 46f73ce33478734dabd5a93d425f7148b60198e1 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Wed, 8 Sep 2021 21:31:06 -0500 +Subject: [PATCH 84/90] spi: sunxi: Hack up the driver for the D1 + +Signed-off-by: Samuel Holland +--- + drivers/spi/spi-sunxi.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/spi/spi-sunxi.c ++++ b/drivers/spi/spi-sunxi.c +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -85,7 +86,7 @@ DECLARE_GLOBAL_DATA_PTR; + #define SUN4I_SPI_DEFAULT_RATE 1000000 + #define SUN4I_SPI_TIMEOUT_MS 1000 + +-#define SPI_REG(priv, reg) ((priv)->base + \ ++#define SPI_REG(priv, reg) (void *)((priv)->base + \ + (priv)->variant->regs[reg]) + #define SPI_BIT(priv, bit) ((priv)->variant->bits[bit]) + #define SPI_CS(priv, cs) (((cs) << SPI_BIT(priv, SPI_TCR_CS_SEL)) & \ diff --git a/package/boot/uboot-d1/patches/0085-spi-sunxi-Add-support-for-the-D1.patch b/package/boot/uboot-d1/patches/0085-spi-sunxi-Add-support-for-the-D1.patch new file mode 100644 index 00000000000000..9ae2c144eb2ebd --- /dev/null +++ b/package/boot/uboot-d1/patches/0085-spi-sunxi-Add-support-for-the-D1.patch @@ -0,0 +1,23 @@ +From 4993c31d314d5c7ebad1d08e3e3f79694dca8738 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 11 Sep 2021 23:12:06 -0500 +Subject: [PATCH 85/90] spi: sunxi: Add support for the D1 + +Signed-off-by: Samuel Holland +--- + drivers/spi/spi-sunxi.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/spi/spi-sunxi.c ++++ b/drivers/spi/spi-sunxi.c +@@ -558,6 +558,10 @@ static const struct udevice_id sun4i_spi + .compatible = "allwinner,sun8i-h3-spi", + .data = (ulong)&sun8i_h3_spi_variant, + }, ++ { ++ .compatible = "allwinner,sun50i-r329-spi", ++ .data = (ulong)&sun8i_h3_spi_variant, ++ }, + { /* sentinel */ } + }; + diff --git a/package/boot/uboot-d1/patches/0086-usb-musb-new-Hack-up-the-driver-for-the-D1.patch b/package/boot/uboot-d1/patches/0086-usb-musb-new-Hack-up-the-driver-for-the-D1.patch new file mode 100644 index 00000000000000..f76cb86131eb29 --- /dev/null +++ b/package/boot/uboot-d1/patches/0086-usb-musb-new-Hack-up-the-driver-for-the-D1.patch @@ -0,0 +1,91 @@ +From eb0cf5922cf0656a7e9f96d6b83397469a26825a Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 11 Sep 2021 10:12:24 -0500 +Subject: [PATCH 86/90] usb: musb-new: Hack up the driver for the D1 + +Signed-off-by: Samuel Holland +--- + arch/riscv/include/asm/bitops.h | 1 + + arch/riscv/include/asm/io.h | 2 +- + arch/riscv/include/asm/processor.h | 2 ++ + drivers/usb/musb-new/musb_io.h | 2 +- + drivers/usb/musb-new/sunxi.c | 6 ++++-- + 5 files changed, 9 insertions(+), 4 deletions(-) + +--- a/arch/riscv/include/asm/bitops.h ++++ b/arch/riscv/include/asm/bitops.h +@@ -78,6 +78,7 @@ static inline int __test_and_set_bit(int + return retval; + } + ++#define test_and_clear_bit __test_and_clear_bit + static inline int __test_and_clear_bit(int nr, void *addr) + { + int mask, retval; +--- a/arch/riscv/include/asm/io.h ++++ b/arch/riscv/include/asm/io.h +@@ -218,6 +218,7 @@ static inline u64 readq(const volatile v + #define insb(p, d, l) readsb(__io(p), d, l) + #define insw(p, d, l) readsw(__io(p), d, l) + #define insl(p, d, l) readsl(__io(p), d, l) ++#endif + + static inline void readsb(unsigned int *addr, void *data, int bytelen) + { +@@ -308,7 +309,6 @@ static inline void writesl(unsigned int + longlen--; + } + } +-#endif + + #define outb_p(val, port) outb((val), (port)) + #define outw_p(val, port) outw((val), (port)) +--- a/arch/riscv/include/asm/processor.h ++++ b/arch/riscv/include/asm/processor.h +@@ -23,4 +23,6 @@ + * no one uses the macros defined in this head file. + **************************************************************/ + ++#define cpu_relax() barrier() ++ + #endif /* __ASM_RISCV_PROCESSOR_H */ +--- a/drivers/usb/musb-new/musb_io.h ++++ b/drivers/usb/musb-new/musb_io.h +@@ -23,7 +23,7 @@ + #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \ + && !defined(CONFIG_PPC32) \ + && !defined(CONFIG_PPC64) && !defined(CONFIG_MIPS) \ +- && !defined(CONFIG_M68K) ++ && !defined(CONFIG_M68K) && !defined(CONFIG_RISCV) + static inline void readsl(const void __iomem *addr, void *buf, int len) + { insl((unsigned long)addr, buf, len); } + static inline void readsw(const void __iomem *addr, void *buf, int len) +--- a/drivers/usb/musb-new/sunxi.c ++++ b/drivers/usb/musb-new/sunxi.c +@@ -23,8 +23,8 @@ + #include + #include + #include +-#include +-#include ++//#include ++//#include + #include + #include + #include +@@ -174,6 +174,7 @@ static void USBC_ForceVbusValidToHigh(__ + + static void USBC_ConfigFIFO_Base(void) + { ++#if 0 + u32 reg_value; + + /* config usb fifo, 8kb mode */ +@@ -181,6 +182,7 @@ static void USBC_ConfigFIFO_Base(void) + reg_value &= ~(0x03 << 0); + reg_value |= BIT(0); + writel(reg_value, SUNXI_SRAMC_BASE + 0x04); ++#endif + } + + /****************************************************************************** diff --git a/package/boot/uboot-d1/patches/0087-sunxi-Add-temporary-RISC-V-version-of-board-code.patch b/package/boot/uboot-d1/patches/0087-sunxi-Add-temporary-RISC-V-version-of-board-code.patch new file mode 100644 index 00000000000000..c066f291628bd6 --- /dev/null +++ b/package/boot/uboot-d1/patches/0087-sunxi-Add-temporary-RISC-V-version-of-board-code.patch @@ -0,0 +1,725 @@ +From e3152c690732fb141500379f32fbe2203fa47059 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Sat, 6 Aug 2022 00:48:38 -0500 +Subject: [PATCH 87/90] sunxi: Add temporary RISC-V version of board code + +Signed-off-by: Samuel Holland +--- + board/sunxi/Makefile | 3 +- + board/sunxi/board-riscv.c | 687 +++++++++++++++++++++++++++++++++ + include/configs/sunxi-common.h | 1 - + 3 files changed, 689 insertions(+), 2 deletions(-) + create mode 100644 board/sunxi/board-riscv.c + +--- a/board/sunxi/Makefile ++++ b/board/sunxi/Makefile +@@ -6,7 +6,8 @@ + # + # (C) Copyright 2000-2003 + # Wolfgang Denk, DENX Software Engineering, wd@denx.de. +-obj-y += board.o ++obj-$(CONFIG_ARM) += board.o ++obj-$(CONFIG_RISCV) += board-riscv.o + obj-$(CONFIG_SUN7I_GMAC) += gmac.o + obj-$(CONFIG_MACH_SUN4I) += dram_sun4i_auto.o + obj-$(CONFIG_MACH_SUN5I) += dram_sun5i_auto.o +--- /dev/null ++++ b/board/sunxi/board-riscv.c +@@ -0,0 +1,687 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * (C) Copyright 2012-2013 Henrik Nordstrom ++ * (C) Copyright 2013 Luke Kenneth Casson Leighton ++ * ++ * (C) Copyright 2007-2011 ++ * Allwinner Technology Co., Ltd. ++ * Tom Cubie ++ * ++ * Some board init for the Allwinner A10-evb board. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef CONFIG_RISCV ++int board_init(void) ++{ ++ /* https://lore.kernel.org/u-boot/31587574-4cd1-02da-9761-0134ac82b94b@sholland.org/ */ ++ return cpu_probe_all(); ++} ++ ++int sunxi_get_sid(unsigned int *sid) ++{ ++ return -ENODEV; ++} ++ ++#define SPL_ADDR CONFIG_SUNXI_SRAM_ADDRESS ++ ++/* The low 8-bits of the 'boot_media' field in the SPL header */ ++#define SUNXI_BOOTED_FROM_MMC0 0 ++#define SUNXI_BOOTED_FROM_NAND 1 ++#define SUNXI_BOOTED_FROM_MMC2 2 ++#define SUNXI_BOOTED_FROM_SPI 3 ++#define SUNXI_BOOTED_FROM_MMC0_HIGH 0x10 ++#define SUNXI_BOOTED_FROM_MMC2_HIGH 0x12 ++ ++#define SUNXI_INVALID_BOOT_SOURCE -1 ++ ++static int sunxi_egon_valid(struct boot_file_head *egon_head) ++{ ++ return !memcmp(egon_head->magic, BOOT0_MAGIC, 8); /* eGON.BT0 */ ++} ++ ++static int sunxi_toc0_valid(struct toc0_main_info *toc0_info) ++{ ++ return !memcmp(toc0_info->name, TOC0_MAIN_INFO_NAME, 8); /* TOC0.GLH */ ++} ++ ++static int sunxi_get_boot_source(void) ++{ ++ struct boot_file_head *egon_head = (void *)SPL_ADDR; ++ struct toc0_main_info *toc0_info = (void *)SPL_ADDR; ++ ++ /* ++ * On the ARMv5 SoCs, the SPL header in SRAM is overwritten by the ++ * exception vectors in U-Boot proper, so we won't find any ++ * information there. Also the FEL stash is only valid in the SPL, ++ * so we can't use that either. So if this is called from U-Boot ++ * proper, just return MMC0 as a placeholder, for now. ++ */ ++ if (IS_ENABLED(CONFIG_MACH_SUNIV) && ++ !IS_ENABLED(CONFIG_SPL_BUILD)) ++ return SUNXI_BOOTED_FROM_MMC0; ++ ++ if (sunxi_egon_valid(egon_head)) ++ return readb(&egon_head->boot_media); ++ if (sunxi_toc0_valid(toc0_info)) ++ return readb(&toc0_info->platform[0]); ++ ++ /* Not a valid image, so we must have been booted via FEL. */ ++ return SUNXI_INVALID_BOOT_SOURCE; ++} ++ ++/* The sunxi internal brom will try to loader external bootloader ++ * from mmc0, nand flash, mmc2. ++ */ ++uint32_t sunxi_get_boot_device(void) ++{ ++ int boot_source = sunxi_get_boot_source(); ++ ++ /* ++ * When booting from the SD card or NAND memory, the "eGON.BT0" ++ * signature is expected to be found in memory at the address 0x0004 ++ * (see the "mksunxiboot" tool, which generates this header). ++ * ++ * When booting in the FEL mode over USB, this signature is patched in ++ * memory and replaced with something else by the 'fel' tool. This other ++ * signature is selected in such a way, that it can't be present in a ++ * valid bootable SD card image (because the BROM would refuse to ++ * execute the SPL in this case). ++ * ++ * This checks for the signature and if it is not found returns to ++ * the FEL code in the BROM to wait and receive the main u-boot ++ * binary over USB. If it is found, it determines where SPL was ++ * read from. ++ */ ++ switch (boot_source) { ++ case SUNXI_INVALID_BOOT_SOURCE: ++ return BOOT_DEVICE_BOARD; ++ case SUNXI_BOOTED_FROM_MMC0: ++ case SUNXI_BOOTED_FROM_MMC0_HIGH: ++ return BOOT_DEVICE_MMC1; ++ case SUNXI_BOOTED_FROM_NAND: ++ return BOOT_DEVICE_NAND; ++ case SUNXI_BOOTED_FROM_MMC2: ++ case SUNXI_BOOTED_FROM_MMC2_HIGH: ++ return BOOT_DEVICE_MMC2; ++ case SUNXI_BOOTED_FROM_SPI: ++ return BOOT_DEVICE_SPI; ++ } ++ ++ panic("Unknown boot source %d\n", boot_source); ++ return -1; /* Never reached */ ++} ++ ++uint32_t sunxi_get_spl_size(void) ++{ ++ struct boot_file_head *egon_head = (void *)SPL_ADDR; ++ struct toc0_main_info *toc0_info = (void *)SPL_ADDR; ++ ++ if (sunxi_egon_valid(egon_head)) ++ return readl(&egon_head->length); ++ if (sunxi_toc0_valid(toc0_info)) ++ return readl(&toc0_info->length); ++ ++ /* Not a valid image, so use the default U-Boot offset. */ ++ return 0; ++} ++ ++/* ++ * The eGON SPL image can be located at 8KB or at 128KB into an SD card or ++ * an eMMC device. The boot source has bit 4 set in the latter case. ++ * By adding 120KB to the normal offset when booting from a "high" location ++ * we can support both cases. ++ * Also U-Boot proper is located at least 32KB after the SPL, but will ++ * immediately follow the SPL if that is bigger than that. ++ */ ++unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ++ unsigned long raw_sect) ++{ ++ unsigned long spl_size = sunxi_get_spl_size(); ++ unsigned long sector; ++ ++ sector = max(raw_sect, spl_size / 512); ++ ++ switch (sunxi_get_boot_source()) { ++ case SUNXI_BOOTED_FROM_MMC0_HIGH: ++ case SUNXI_BOOTED_FROM_MMC2_HIGH: ++ sector += (128 - 8) * 2; ++ break; ++ } ++ ++ printf("SPL size = %lu, sector = %lu\n", spl_size, sector); ++ ++ return sector; ++} ++ ++u32 spl_boot_device(void) ++{ ++ return sunxi_get_boot_device(); ++} ++ ++#define CSR_MXSTATUS 0x7c0 ++#define CSR_MHCR 0x7c1 ++#define CSR_MCOR 0x7c2 ++#define CSR_MHINT 0x7c5 ++ ++int spl_board_init_f(void) ++{ ++ int ret; ++ struct udevice *dev; ++ ++ /* DDR init */ ++ ret = uclass_get_device(UCLASS_RAM, 0, &dev); ++ if (ret) { ++ debug("DRAM init failed: %d\n", ret); ++ return ret; ++ } ++ ++ /* Initialize extension CSRs. */ ++ printf("mxstatus=0x%08lx mhcr=0x%08lx mcor=0x%08lx mhint=0x%08lx\n", ++ csr_read(CSR_MXSTATUS), ++ csr_read(CSR_MHCR), ++ csr_read(CSR_MCOR), ++ csr_read(CSR_MHINT)); ++ ++ csr_set(CSR_MXSTATUS, 0x638000); ++ csr_write(CSR_MCOR, 0x70013); ++ csr_write(CSR_MHCR, 0x11ff); ++ csr_write(CSR_MHINT, 0x16e30c); ++ ++ return 0; ++} ++ ++#ifdef CONFIG_SPL_BUILD ++void spl_perform_fixups(struct spl_image_info *spl_image) ++{ ++ struct ram_info info; ++ struct udevice *dev; ++ int ret; ++ ++ ret = uclass_get_device(UCLASS_RAM, 0, &dev); ++ if (ret) ++ panic("No RAM device"); ++ ++ ret = ram_get_info(dev, &info); ++ if (ret) ++ panic("No RAM info"); ++ ++ ret = fdt_fixup_memory(spl_image->fdt_addr, info.base, info.size); ++ if (ret) ++ panic("Failed to update DTB"); ++} ++#endif ++#endif ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++/* ++ * Try to use the environment from the boot source first. ++ * For MMC, this means a FAT partition on the boot device (SD or eMMC). ++ * If the raw MMC environment is also enabled, this is tried next. ++ * When booting from NAND we try UBI first, then NAND directly. ++ * SPI flash falls back to FAT (on SD card). ++ */ ++enum env_location env_get_location(enum env_operation op, int prio) ++{ ++ if (prio > 1) ++ return ENVL_UNKNOWN; ++ ++ /* NOWHERE is exclusive, no other option can be defined. */ ++ if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE)) ++ return ENVL_NOWHERE; ++ ++ switch (sunxi_get_boot_device()) { ++ case BOOT_DEVICE_MMC1: ++ case BOOT_DEVICE_MMC2: ++ if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) ++ return ENVL_FAT; ++ if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC)) ++ return ENVL_MMC; ++ break; ++ case BOOT_DEVICE_NAND: ++ if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) ++ return ENVL_UBI; ++ if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND)) ++ return ENVL_NAND; ++ break; ++ case BOOT_DEVICE_SPI: ++ if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)) ++ return ENVL_SPI_FLASH; ++ if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) ++ return ENVL_FAT; ++ break; ++ case BOOT_DEVICE_BOARD: ++ break; ++ default: ++ break; ++ } ++ ++ /* ++ * If we come here for the first time, we *must* return a valid ++ * environment location other than ENVL_UNKNOWN, or the setup sequence ++ * in board_f() will silently hang. This is arguably a bug in ++ * env_init(), but for now pick one environment for which we know for ++ * sure to have a driver for. For all defconfigs this is either FAT ++ * or UBI, or NOWHERE, which is already handled above. ++ */ ++ if (prio == 0) { ++ if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) ++ return ENVL_FAT; ++ if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) ++ return ENVL_UBI; ++ } ++ ++ return ENVL_UNKNOWN; ++} ++ ++/* ++ * On older SoCs the SPL is actually at address zero, so using NULL as ++ * an error value does not work. ++ */ ++#define INVALID_SPL_HEADER ((void *)~0UL) ++ ++static struct boot_file_head * get_spl_header(uint8_t req_version) ++{ ++ struct boot_file_head *spl = (void *)(ulong)SPL_ADDR; ++ uint8_t spl_header_version = spl->spl_signature[3]; ++ ++ /* Is there really the SPL header (still) there? */ ++ if (memcmp(spl->spl_signature, SPL_SIGNATURE, 3) != 0) ++ return INVALID_SPL_HEADER; ++ ++ if (spl_header_version < req_version) { ++ printf("sunxi SPL version mismatch: expected %u, got %u\n", ++ req_version, spl_header_version); ++ return INVALID_SPL_HEADER; ++ } ++ ++ return spl; ++} ++ ++static const char *get_spl_dt_name(void) ++{ ++ struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION); ++ ++ /* Check if there is a DT name stored in the SPL header. */ ++ if (spl != INVALID_SPL_HEADER && spl->dt_name_offset) ++ return (char *)spl + spl->dt_name_offset; ++ ++ return NULL; ++} ++ ++#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1 ++int mmc_get_env_dev(void) ++{ ++ switch (sunxi_get_boot_device()) { ++ case BOOT_DEVICE_MMC1: ++ return 0; ++ case BOOT_DEVICE_MMC2: ++ return 1; ++ default: ++ return CONFIG_SYS_MMC_ENV_DEV; ++ } ++} ++#endif ++ ++#ifdef CONFIG_SPL_BUILD ++void sunxi_board_init(void) ++{ ++#ifdef CONFIG_LED_STATUS ++ if (IS_ENABLED(CONFIG_SPL_DRIVERS_MISC)) ++ status_led_init(); ++#endif ++} ++#endif ++ ++#ifdef CONFIG_USB_GADGET ++int g_dnl_board_usb_cable_connected(void) ++{ ++ struct udevice *dev; ++ struct phy phy; ++ int ret; ++ ++ ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev); ++ if (ret) { ++ pr_err("%s: Cannot find USB device\n", __func__); ++ return ret; ++ } ++ ++ ret = generic_phy_get_by_name(dev, "usb", &phy); ++ if (ret) { ++ pr_err("failed to get %s USB PHY\n", dev->name); ++ return ret; ++ } ++ ++ ret = generic_phy_init(&phy); ++ if (ret) { ++ pr_debug("failed to init %s USB PHY\n", dev->name); ++ return ret; ++ } ++ ++ return sun4i_usb_phy_vbus_detect(&phy); ++} ++#endif ++ ++#ifdef CONFIG_SERIAL_TAG ++void get_board_serial(struct tag_serialnr *serialnr) ++{ ++ char *serial_string; ++ unsigned long long serial; ++ ++ serial_string = env_get("serial#"); ++ ++ if (serial_string) { ++ serial = simple_strtoull(serial_string, NULL, 16); ++ ++ serialnr->high = (unsigned int) (serial >> 32); ++ serialnr->low = (unsigned int) (serial & 0xffffffff); ++ } else { ++ serialnr->high = 0; ++ serialnr->low = 0; ++ } ++} ++#endif ++ ++/* ++ * Check the SPL header for the "sunxi" variant. If found: parse values ++ * that might have been passed by the loader ("fel" utility), and update ++ * the environment accordingly. ++ */ ++static void parse_spl_header(const uint32_t spl_addr) ++{ ++ struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION); ++ ++ if (spl == INVALID_SPL_HEADER) ++ return; ++ ++ if (!spl->fel_script_address) ++ return; ++ ++ if (spl->fel_uEnv_length != 0) { ++ /* ++ * data is expected in uEnv.txt compatible format, so "env ++ * import -t" the string(s) at fel_script_address right away. ++ */ ++ himport_r(&env_htab, (char *)(uintptr_t)spl->fel_script_address, ++ spl->fel_uEnv_length, '\n', H_NOCLEAR, 0, 0, NULL); ++ return; ++ } ++ /* otherwise assume .scr format (mkimage-type script) */ ++ env_set_hex("fel_scriptaddr", spl->fel_script_address); ++} ++ ++static bool get_unique_sid(unsigned int *sid) ++{ ++ if (sunxi_get_sid(sid) != 0) ++ return false; ++ ++ if (!sid[0]) ++ return false; ++ ++ /* ++ * The single words 1 - 3 of the SID have quite a few bits ++ * which are the same on many models, so we take a crc32 ++ * of all 3 words, to get a more unique value. ++ * ++ * Note we only do this on newer SoCs as we cannot change ++ * the algorithm on older SoCs since those have been using ++ * fixed mac-addresses based on only using word 3 for a ++ * long time and changing a fixed mac-address with an ++ * u-boot update is not good. ++ */ ++#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ ++ !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \ ++ !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33) ++ sid[3] = crc32(0, (unsigned char *)&sid[1], 12); ++#endif ++ ++ /* Ensure the NIC specific bytes of the mac are not all 0 */ ++ if ((sid[3] & 0xffffff) == 0) ++ sid[3] |= 0x800000; ++ ++ return true; ++} ++ ++/* ++ * Note this function gets called multiple times. ++ * It must not make any changes to env variables which already exist. ++ */ ++static void setup_environment(const void *fdt) ++{ ++ char serial_string[17] = { 0 }; ++ unsigned int sid[4]; ++ uint8_t mac_addr[6]; ++ char ethaddr[16]; ++ int i; ++ ++ if (!get_unique_sid(sid)) ++ return; ++ ++ for (i = 0; i < 4; i++) { ++ sprintf(ethaddr, "ethernet%d", i); ++ if (!fdt_get_alias(fdt, ethaddr)) ++ continue; ++ ++ if (i == 0) ++ strcpy(ethaddr, "ethaddr"); ++ else ++ sprintf(ethaddr, "eth%daddr", i); ++ ++ if (env_get(ethaddr)) ++ continue; ++ ++ /* Non OUI / registered MAC address */ ++ mac_addr[0] = (i << 4) | 0x02; ++ mac_addr[1] = (sid[0] >> 0) & 0xff; ++ mac_addr[2] = (sid[3] >> 24) & 0xff; ++ mac_addr[3] = (sid[3] >> 16) & 0xff; ++ mac_addr[4] = (sid[3] >> 8) & 0xff; ++ mac_addr[5] = (sid[3] >> 0) & 0xff; ++ ++ eth_env_set_enetaddr(ethaddr, mac_addr); ++ } ++ ++ if (!env_get("serial#")) { ++ snprintf(serial_string, sizeof(serial_string), ++ "%08x%08x", sid[0], sid[3]); ++ ++ env_set("serial#", serial_string); ++ } ++} ++ ++int misc_init_r(void) ++{ ++ const char *spl_dt_name; ++ uint boot; ++ ++ env_set("fel_booted", NULL); ++ env_set("fel_scriptaddr", NULL); ++ env_set("mmc_bootdev", NULL); ++ ++ boot = sunxi_get_boot_device(); ++ /* determine if we are running in FEL mode */ ++ if (boot == BOOT_DEVICE_BOARD) { ++ env_set("fel_booted", "1"); ++ parse_spl_header(SPL_ADDR); ++ /* or if we booted from MMC, and which one */ ++ } else if (boot == BOOT_DEVICE_MMC1) { ++ env_set("mmc_bootdev", "0"); ++ } else if (boot == BOOT_DEVICE_MMC2) { ++ env_set("mmc_bootdev", "1"); ++ } ++ ++ /* Set fdtfile to match the FIT configuration chosen in SPL. */ ++ spl_dt_name = get_spl_dt_name(); ++ if (spl_dt_name) { ++ char *prefix = IS_ENABLED(CONFIG_ARM64) ? "allwinner/" : ""; ++ char str[64]; ++ ++ snprintf(str, sizeof(str), "%s%s.dtb", prefix, spl_dt_name); ++ env_set("fdtfile", str); ++ } ++ ++ setup_environment(gd->fdt_blob); ++ ++ return 0; ++} ++ ++int board_late_init(void) ++{ ++#ifdef CONFIG_USB_ETHER ++ usb_ether_init(); ++#endif ++ ++#ifdef SUNXI_SCP_BASE ++ if (!rproc_load(0, SUNXI_SCP_BASE, SUNXI_SCP_MAX_SIZE)) { ++ puts("Starting SCP...\n"); ++ rproc_start(0); ++ } ++#endif ++ ++ return 0; ++} ++ ++static void bluetooth_dt_fixup(void *blob) ++{ ++ /* Some devices ship with a Bluetooth controller default address. ++ * Set a valid address through the device tree. ++ */ ++ uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; ++ unsigned int sid[4]; ++ int i; ++ ++ if (!CONFIG_BLUETOOTH_DT_DEVICE_FIXUP[0]) ++ return; ++ ++ if (eth_env_get_enetaddr("bdaddr", tmp)) { ++ /* Convert between the binary formats of the corresponding stacks */ ++ for (i = 0; i < ETH_ALEN; ++i) ++ bdaddr[i] = tmp[ETH_ALEN - i - 1]; ++ } else { ++ if (!get_unique_sid(sid)) ++ return; ++ ++ bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1; ++ bdaddr[1] = (sid[3] >> 8) & 0xff; ++ bdaddr[2] = (sid[3] >> 16) & 0xff; ++ bdaddr[3] = (sid[3] >> 24) & 0xff; ++ bdaddr[4] = (sid[0] >> 0) & 0xff; ++ bdaddr[5] = 0x02; ++ } ++ ++ do_fixup_by_compat(blob, CONFIG_BLUETOOTH_DT_DEVICE_FIXUP, ++ "local-bd-address", bdaddr, ETH_ALEN, 1); ++} ++ ++int ft_board_setup(void *blob, struct bd_info *bd) ++{ ++ int __maybe_unused r; ++ ++ /* ++ * Call setup_environment and fdt_fixup_ethernet again ++ * in case the boot fdt has ethernet aliases the u-boot ++ * copy does not have. ++ */ ++ setup_environment(blob); ++ fdt_fixup_ethernet(blob); ++ ++ bluetooth_dt_fixup(blob); ++ ++#ifdef CONFIG_VIDEO_DT_SIMPLEFB ++ r = sunxi_simplefb_setup(blob); ++ if (r) ++ return r; ++#endif ++ return 0; ++} ++ ++#ifdef CONFIG_SPL_LOAD_FIT ++ ++static void set_spl_dt_name(const char *name) ++{ ++ struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION); ++ ++ if (spl == INVALID_SPL_HEADER) ++ return; ++ ++ /* Promote the header version for U-Boot proper, if needed. */ ++ if (spl->spl_signature[3] < SPL_DT_HEADER_VERSION) ++ spl->spl_signature[3] = SPL_DT_HEADER_VERSION; ++ ++ strcpy((char *)&spl->string_pool, name); ++ spl->dt_name_offset = offsetof(struct boot_file_head, string_pool); ++} ++ ++int board_fit_config_name_match(const char *name) ++{ ++ const char *best_dt_name = get_spl_dt_name(); ++ int ret; ++ ++#ifdef CONFIG_DEFAULT_DEVICE_TREE ++ if (best_dt_name == NULL) ++ best_dt_name = CONFIG_DEFAULT_DEVICE_TREE; ++#endif ++ ++ if (best_dt_name == NULL) { ++ /* No DT name was provided, so accept the first config. */ ++ return 0; ++ } ++#ifdef CONFIG_PINE64_DT_SELECTION ++ if (strstr(best_dt_name, "-pine64-plus")) { ++ /* Differentiate the Pine A64 boards by their DRAM size. */ ++ if ((gd->ram_size == 512 * 1024 * 1024)) ++ best_dt_name = "sun50i-a64-pine64"; ++ } ++#endif ++#ifdef CONFIG_PINEPHONE_DT_SELECTION ++ if (strstr(best_dt_name, "-pinephone")) { ++ /* Differentiate the PinePhone revisions by GPIO inputs. */ ++ prcm_apb0_enable(PRCM_APB0_GATE_PIO); ++ sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_UP); ++ sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_INPUT); ++ udelay(100); ++ ++ /* PL6 is pulled low by the modem on v1.2. */ ++ if (gpio_get_value(SUNXI_GPL(6)) == 0) ++ best_dt_name = "sun50i-a64-pinephone-1.2"; ++ else ++ best_dt_name = "sun50i-a64-pinephone-1.1"; ++ ++ sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_DISABLE); ++ sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_DISABLE); ++ prcm_apb0_disable(PRCM_APB0_GATE_PIO); ++ } ++#endif ++ ++ ret = strcmp(name, best_dt_name); ++ ++ /* ++ * If one of the FIT configurations matches the most accurate DT name, ++ * update the SPL header to provide that DT name to U-Boot proper. ++ */ ++ if (ret == 0) ++ set_spl_dt_name(best_dt_name); ++ ++ return ret; ++} ++#endif +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -12,7 +12,6 @@ + #ifndef _SUNXI_COMMON_CONFIG_H + #define _SUNXI_COMMON_CONFIG_H + +-#include + #include + + /* Serial & console */ diff --git a/package/boot/uboot-d1/patches/0088-sunxi-riscv-Copy-in-WIP-version-of-devicetrees.patch b/package/boot/uboot-d1/patches/0088-sunxi-riscv-Copy-in-WIP-version-of-devicetrees.patch new file mode 100644 index 00000000000000..95ed7b202718e6 --- /dev/null +++ b/package/boot/uboot-d1/patches/0088-sunxi-riscv-Copy-in-WIP-version-of-devicetrees.patch @@ -0,0 +1,1327 @@ +From 197d4096c697bcde8f9833b1d04b17eb2b232b85 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 31 Oct 2022 22:59:00 -0500 +Subject: [PATCH 88/90] sunxi: riscv: Copy in WIP version of devicetrees + +While the bindings still are not stable, this should help things work +out of the box. + +Signed-off-by: Samuel Holland +--- + .../riscv/dts/sun20i-d1-clockworkpi-v3.14.dts | 134 +++++++- + .../dts/sun20i-d1-common-regulators.dtsi | 13 + + arch/riscv/dts/sun20i-d1-devterm-v3.14.dts | 16 + + .../dts/sun20i-d1-dongshan-nezha-stu.dts | 48 ++- + .../dts/sun20i-d1-lichee-rv-86-panel-480p.dts | 51 +++ + .../dts/sun20i-d1-lichee-rv-86-panel.dtsi | 64 ++++ + arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts | 98 ++++++ + arch/riscv/dts/sun20i-d1-lichee-rv.dts | 6 + + arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts | 41 +++ + arch/riscv/dts/sun20i-d1-nezha.dts | 117 ++++++- + arch/riscv/dts/sun20i-d1.dtsi | 314 +++++++++++++++++- + 11 files changed, 881 insertions(+), 21 deletions(-) + +--- a/arch/riscv/dts/sun20i-d1-clockworkpi-v3.14.dts ++++ b/arch/riscv/dts/sun20i-d1-clockworkpi-v3.14.dts +@@ -22,16 +22,78 @@ + stdout-path = "serial0:115200n8"; + }; + ++ audio_amplifier: audio-amplifier { ++ compatible = "simple-audio-amplifier"; ++ enable-gpios = <&pio 4 1 GPIO_ACTIVE_HIGH>; /* PE1/GPIO11 */ ++ sound-name-prefix = "Amplifier"; ++ VCC-supply = <®_vcc>; ++ }; ++ ++ /* ++ * FIXME: This is not really an amplifier, but the amplifier binding ++ * has the needed properties and behavior. ++ */ ++ audio_switch: audio-switch { ++ compatible = "simple-audio-amplifier"; ++ enable-gpios = <&pio 1 2 GPIO_ACTIVE_HIGH>; /* PB2/AUD_SWITCH */ ++ sound-name-prefix = "Switch"; ++ VCC-supply = <®_aldo1>; ++ }; ++ ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ power-supply = <®_vcc>; ++ pwms = <&pwm 4 50000 0>; /* PD20/GPIO9 */ ++ }; ++ ++ bt_sco_codec: bt-sco-codec { ++ #sound-dai-cells = <0>; ++ compatible = "linux,bt-sco"; ++ }; ++ ++ bt-sound { ++ compatible = "simple-audio-card"; ++ simple-audio-card,name = "Bluetooth"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ simple-audio-card,dai-link@0 { ++ format = "dsp_a"; ++ frame-master = <&bt_sound_cpu>; ++ bitclock-master = <&bt_sound_cpu>; ++ ++ bt_sound_cpu: cpu { ++ sound-dai = <&i2s1>; ++ }; ++ ++ codec { ++ sound-dai = <&bt_sco_codec>; ++ }; ++ }; ++ }; ++ ++ hdmi_connector: connector { ++ compatible = "hdmi-connector"; ++ type = "d"; ++ ++ port { ++ hdmi_connector_in: endpoint { ++ remote-endpoint = <&hdmi_out_connector>; ++ }; ++ }; ++ }; ++ + /* + * This regulator is PWM-controlled, but the PWM controller is not + * yet supported, so fix the regulator to its default voltage. + */ + reg_vdd_cpu: vdd-cpu { +- compatible = "regulator-fixed"; ++ compatible = "pwm-regulator"; ++ pwms = <&pwm 0 50000 0>; ++ pwm-supply = <®_vcc>; + regulator-name = "vdd-cpu"; +- regulator-min-microvolt = <1100000>; +- regulator-max-microvolt = <1100000>; +- vin-supply = <®_vcc>; ++ regulator-min-microvolt = <810000>; ++ regulator-max-microvolt = <1160000>; + }; + + wifi_pwrseq: wifi-pwrseq { +@@ -40,14 +102,51 @@ + }; + }; + ++&codec { ++ aux-devs = <&audio_amplifier>, <&audio_switch>; ++ hp-det-gpio = <&pio 1 12 GPIO_ACTIVE_HIGH>; /* PB12/GPIO10 */ ++ pin-switches = "Internal Speakers"; ++ routing = "Internal Speakers", "Amplifier OUTL", ++ "Internal Speakers", "Amplifier OUTR", ++ "Amplifier INL", "Switch OUTL", ++ "Amplifier INR", "Switch OUTR", ++ "Headphone Jack", "Switch OUTL", ++ "Headphone Jack", "Switch OUTR", ++ "Switch INL", "HPOUTL", ++ "Switch INR", "HPOUTR", ++ "MICIN3", "Headset Microphone", ++ "Headset Microphone", "HBIAS"; ++ widgets = "Microphone", "Headset Microphone", ++ "Headphone", "Headphone Jack", ++ "Speaker", "Internal Speakers"; ++}; ++ + &cpu0 { + cpu-supply = <®_vdd_cpu>; + }; + ++&de { ++ status = "okay"; ++}; ++ + &ehci1 { + status = "okay"; + }; + ++&hdmi { ++ status = "okay"; ++}; ++ ++&hdmi_out { ++ hdmi_out_connector: endpoint { ++ remote-endpoint = <&hdmi_connector_in>; ++ }; ++}; ++ ++&hdmi_phy { ++ status = "okay"; ++}; ++ + &i2c0 { + pinctrl-0 = <&i2c0_pb10_pins>; + pinctrl-names = "default"; +@@ -169,6 +268,12 @@ + }; + }; + ++&i2s1 { ++ pinctrl-0 = <&i2s1_clk_pins>, <&i2s1_din_pin>, <&i2s1_dout_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &mmc0 { + broken-cd; + bus-width = <4>; +@@ -205,6 +310,27 @@ + + &pio { + vcc-pg-supply = <®_ldoa>; ++ ++ i2s1_clk_pins: i2s1-clk-pins { ++ pins = "PG12", "PG13"; ++ function = "i2s1"; ++ }; ++ ++ i2s1_din_pin: i2s1-din-pin { ++ pins = "PG14"; ++ function = "i2s1_din"; ++ }; ++ ++ i2s1_dout_pin: i2s1-dout-pin { ++ pins = "PG15"; ++ function = "i2s1_dout"; ++ }; ++}; ++ ++&pwm { ++ pinctrl-0 = <&pwm0_pd16_pin>, <&pwm4_pd20_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; + }; + + &uart0 { +--- a/arch/riscv/dts/sun20i-d1-common-regulators.dtsi ++++ b/arch/riscv/dts/sun20i-d1-common-regulators.dtsi +@@ -18,6 +18,15 @@ + }; + }; + ++&codec { ++ avcc-supply = <®_aldo>; ++ hpvcc-supply = <®_hpldo>; ++}; ++ ++&hdmi { ++ hvcc-supply = <®_ldoa>; ++}; ++ + &lradc { + vref-supply = <®_aldo>; + }; +@@ -49,3 +58,7 @@ + regulator-max-microvolt = <1800000>; + ldo-in-supply = <®_vcc_3v3>; + }; ++ ++&ths { ++ vref-supply = <®_aldo>; ++}; +--- a/arch/riscv/dts/sun20i-d1-devterm-v3.14.dts ++++ b/arch/riscv/dts/sun20i-d1-devterm-v3.14.dts +@@ -35,3 +35,19 @@ + }; + }; + }; ++ ++&dsi { ++ pinctrl-0 = <&dsi_4lane_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ panel@0 { ++ compatible = "clockwork,cwd686"; ++ reg = <0>; ++ backlight = <&backlight>; ++ reset-gpios = <&pio 3 19 GPIO_ACTIVE_LOW>; /* PD19/GPIO8 */ ++ rotation = <90>; ++ iovcc-supply = <®_dcdc3>; ++ vci-supply = <®_aldo2>; ++ }; ++}; +--- a/arch/riscv/dts/sun20i-d1-dongshan-nezha-stu.dts ++++ b/arch/riscv/dts/sun20i-d1-dongshan-nezha-stu.dts +@@ -23,6 +23,17 @@ + stdout-path = "serial0:115200n8"; + }; + ++ hdmi_connector: connector { ++ compatible = "hdmi-connector"; ++ type = "a"; ++ ++ port { ++ hdmi_connector_in: endpoint { ++ remote-endpoint = <&hdmi_out_connector>; ++ }; ++ }; ++ }; ++ + leds { + compatible = "gpio-leds"; + +@@ -43,16 +54,13 @@ + vin-supply = <®_vcc>; + }; + +- /* +- * This regulator is PWM-controlled, but the PWM controller is not +- * yet supported, so fix the regulator to its default voltage. +- */ + reg_vdd_cpu: vdd-cpu { +- compatible = "regulator-fixed"; ++ compatible = "pwm-regulator"; ++ pwms = <&pwm 0 50000 0>; ++ pwm-supply = <®_vcc>; + regulator-name = "vdd-cpu"; +- regulator-min-microvolt = <1100000>; +- regulator-max-microvolt = <1100000>; +- vin-supply = <®_vcc>; ++ regulator-min-microvolt = <810000>; ++ regulator-max-microvolt = <1160000>; + }; + }; + +@@ -60,6 +68,10 @@ + cpu-supply = <®_vdd_cpu>; + }; + ++&de { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -73,6 +85,20 @@ + status = "okay"; + }; + ++&hdmi { ++ status = "okay"; ++}; ++ ++&hdmi_out { ++ hdmi_out_connector: endpoint { ++ remote-endpoint = <&hdmi_connector_in>; ++ }; ++}; ++ ++&hdmi_phy { ++ status = "okay"; ++}; ++ + &mdio { + ext_rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; +@@ -95,6 +121,12 @@ + status = "okay"; + }; + ++&pwm { ++ pinctrl-0 = <&pwm0_pd16_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &uart0 { + pinctrl-0 = <&uart0_pb8_pins>; + pinctrl-names = "default"; +--- a/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-480p.dts ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel-480p.dts +@@ -7,6 +7,40 @@ + model = "Sipeed Lichee RV 86 Panel (480p)"; + compatible = "sipeed,lichee-rv-86-panel-480p", "sipeed,lichee-rv", + "allwinner,sun20i-d1"; ++ ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ power-supply = <®_vcc>; ++ pwms = <&pwm 7 50000 0>; ++ }; ++ ++ spi { ++ compatible = "spi-gpio"; ++ cs-gpios = <&pio 4 14 GPIO_ACTIVE_LOW>; /* PE14 */ ++ mosi-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; /* PE12 */ ++ sck-gpios = <&pio 4 15 GPIO_ACTIVE_HIGH>; /* PE15 */ ++ num-chipselects = <1>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ panel@0 { ++ compatible = "sitronix,st7701s"; ++ reg = <0>; ++ backlight = <&backlight>; ++ reset-gpios = <&pio 6 13 GPIO_ACTIVE_LOW>; /* PG13 */ ++ spi-3wire; ++ ++ port { ++ panel_in_tcon_lcd0: endpoint { ++ remote-endpoint = <&tcon_lcd0_out_panel>; ++ }; ++ }; ++ }; ++ }; ++}; ++ ++&de { ++ status = "okay"; + }; + + &i2c2 { +@@ -27,3 +61,20 @@ + wakeup-source; + }; + }; ++ ++&pwm { ++ pinctrl-0 = <&pwm7_pd22_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&tcon_lcd0 { ++ pinctrl-0 = <&lcd_rgb666_pins>; ++ pinctrl-names = "default"; ++}; ++ ++&tcon_lcd0_out { ++ tcon_lcd0_out_panel: endpoint { ++ remote-endpoint = <&panel_in_tcon_lcd0>; ++ }; ++}; +--- a/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel.dtsi ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel.dtsi +@@ -9,6 +9,39 @@ + ethernet1 = &xr829; + }; + ++ audio_amplifier: audio-amplifier { ++ compatible = "simple-audio-amplifier"; ++ enable-gpios = <&pio 1 10 GPIO_ACTIVE_HIGH>; /* PB10 */ ++ sound-name-prefix = "Amplifier"; ++ }; ++ ++ dmic_codec: dmic-codec { ++ compatible = "dmic-codec"; ++ num-channels = <2>; ++ #sound-dai-cells = <0>; ++ }; ++ ++ dmic-sound { ++ compatible = "simple-audio-card"; ++ simple-audio-card,name = "DMIC"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ simple-audio-card,dai-link@0 { ++ format = "pdm"; ++ frame-master = <&link0_cpu>; ++ bitclock-master = <&link0_cpu>; ++ ++ link0_cpu: cpu { ++ sound-dai = <&dmic>; ++ }; ++ ++ link0_codec: codec { ++ sound-dai = <&dmic_codec>; ++ }; ++ }; ++ }; ++ + /* PC1 is repurposed as BT_WAKE_AP */ + /delete-node/ leds; + +@@ -24,6 +57,27 @@ + }; + }; + ++&codec { ++ aux-devs = <&audio_amplifier>; ++ routing = "Internal Speaker", "Amplifier OUTL", ++ "Internal Speaker", "Amplifier OUTR", ++ "Amplifier INL", "HPOUTL", ++ "Amplifier INR", "HPOUTR", ++ "LINEINL", "HPOUTL", ++ "LINEINR", "HPOUTR", ++ "MICIN3", "Internal Microphone", ++ "Internal Microphone", "HBIAS"; ++ widgets = "Microphone", "Internal Microphone", ++ "Speaker", "Internal Speaker"; ++ status = "okay"; ++}; ++ ++&dmic { ++ pinctrl-0 = <&dmic_pb11_d0_pin>, <&dmic_pe17_clk_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &ehci1 { + status = "okay"; + }; +@@ -69,6 +123,16 @@ + pins = "PG11"; + function = "clk"; + }; ++ ++ dmic_pb11_d0_pin: dmic-pb11-d0-pin { ++ pins = "PB11"; ++ function = "dmic"; ++ }; ++ ++ dmic_pe17_clk_pin: dmic-pe17-clk-pin { ++ pins = "PE17"; ++ function = "dmic"; ++ }; + }; + + &uart1 { +--- a/arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv-dock.dts +@@ -15,16 +15,102 @@ + ethernet1 = &rtl8723ds; + }; + ++ dmic_codec: dmic-codec { ++ compatible = "dmic-codec"; ++ num-channels = <2>; ++ #sound-dai-cells = <0>; ++ }; ++ ++ dmic-sound { ++ compatible = "simple-audio-card"; ++ simple-audio-card,name = "DMIC"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ simple-audio-card,dai-link@0 { ++ format = "pdm"; ++ frame-master = <&link0_cpu>; ++ bitclock-master = <&link0_cpu>; ++ ++ link0_cpu: cpu { ++ sound-dai = <&dmic>; ++ }; ++ ++ link0_codec: codec { ++ sound-dai = <&dmic_codec>; ++ }; ++ }; ++ }; ++ ++ hdmi_connector: connector { ++ compatible = "hdmi-connector"; ++ type = "a"; ++ ++ port { ++ hdmi_connector_in: endpoint { ++ remote-endpoint = <&hdmi_out_connector>; ++ }; ++ }; ++ }; ++ + wifi_pwrseq: wifi-pwrseq { + compatible = "mmc-pwrseq-simple"; + reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ + }; + }; + ++&codec { ++ routing = "Internal Speaker", "HPOUTL", ++ "Internal Speaker", "HPOUTR", ++ "LINEINL", "HPOUTL", ++ "LINEINR", "HPOUTR", ++ "MICIN3", "Internal Microphone", ++ "Internal Microphone", "HBIAS"; ++ widgets = "Microphone", "Internal Microphone", ++ "Speaker", "Internal Speaker"; ++ status = "okay"; ++}; ++ ++&de { ++ status = "okay"; ++}; ++ ++&dmic { ++ pinctrl-0 = <&dmic_pb11_d0_pin>, <&dmic_pe17_clk_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &ehci1 { + status = "okay"; + }; + ++&hdmi { ++ status = "okay"; ++}; ++ ++&hdmi_out { ++ hdmi_out_connector: endpoint { ++ remote-endpoint = <&hdmi_connector_in>; ++ }; ++}; ++ ++&hdmi_phy { ++ status = "okay"; ++}; ++ ++&ledc { ++ pinctrl-0 = <&ledc_pc0_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ multi-led@0 { ++ reg = <0x0>; ++ color = ; ++ function = LED_FUNCTION_STATUS; ++ }; ++}; ++ + &lradc { + status = "okay"; + +@@ -55,6 +141,18 @@ + status = "okay"; + }; + ++&pio { ++ dmic_pb11_d0_pin: dmic-pb11-d0-pin { ++ pins = "PB11"; ++ function = "dmic"; ++ }; ++ ++ dmic_pe17_clk_pin: dmic-pe17-clk-pin { ++ pins = "PE17"; ++ function = "dmic"; ++ }; ++}; ++ + &uart1 { + uart-has-rtscts; + pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>; +--- a/arch/riscv/dts/sun20i-d1-lichee-rv.dts ++++ b/arch/riscv/dts/sun20i-d1-lichee-rv.dts +@@ -65,6 +65,12 @@ + status = "okay"; + }; + ++&spi0 { ++ pinctrl-0 = <&spi0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &uart0 { + pinctrl-0 = <&uart0_pb8_pins>; + pinctrl-names = "default"; +--- a/arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts ++++ b/arch/riscv/dts/sun20i-d1-mangopi-mq-pro.dts +@@ -4,6 +4,7 @@ + /dts-v1/; + + #include ++#include + + #include "sun20i-d1.dtsi" + #include "sun20i-d1-common-regulators.dtsi" +@@ -22,6 +23,28 @@ + stdout-path = "serial0:115200n8"; + }; + ++ hdmi_connector: connector { ++ compatible = "hdmi-connector"; ++ type = "c"; ++ ++ port { ++ hdmi_connector_in: endpoint { ++ remote-endpoint = <&hdmi_out_connector>; ++ }; ++ }; ++ }; ++ ++ leds { ++ compatible = "pwm-leds"; ++ ++ led { ++ color = ; ++ function = LED_FUNCTION_STATUS; ++ max-brightness = <255>; ++ pwms = <&pwm 2 50000 0>; ++ }; ++ }; ++ + reg_avdd2v8: avdd2v8 { + compatible = "regulator-fixed"; + regulator-name = "avdd2v8"; +@@ -56,10 +79,28 @@ + cpu-supply = <®_vdd_cpu>; + }; + ++&de { ++ status = "okay"; ++}; ++ + &ehci1 { + status = "okay"; + }; + ++&hdmi { ++ status = "okay"; ++}; ++ ++&hdmi_out { ++ hdmi_out_connector: endpoint { ++ remote-endpoint = <&hdmi_connector_in>; ++ }; ++}; ++ ++&hdmi_phy { ++ status = "okay"; ++}; ++ + &mmc0 { + bus-width = <4>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ +--- a/arch/riscv/dts/sun20i-d1-nezha.dts ++++ b/arch/riscv/dts/sun20i-d1-nezha.dts +@@ -5,6 +5,7 @@ + + #include + #include ++#include + + #include "sun20i-d1.dtsi" + #include "sun20i-d1-common-regulators.dtsi" +@@ -18,12 +19,24 @@ + ethernet1 = &xr829; + mmc0 = &mmc0; + serial0 = &uart0; ++ spi0 = &spi0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + ++ hdmi_connector: connector { ++ compatible = "hdmi-connector"; ++ type = "a"; ++ ++ port { ++ hdmi_connector_in: endpoint { ++ remote-endpoint = <&hdmi_out_connector>; ++ }; ++ }; ++ }; ++ + reg_usbvbus: usbvbus { + compatible = "regulator-fixed"; + regulator-name = "usbvbus"; +@@ -34,16 +47,13 @@ + vin-supply = <®_vcc>; + }; + +- /* +- * This regulator is PWM-controlled, but the PWM controller is not +- * yet supported, so fix the regulator to its default voltage. +- */ + reg_vdd_cpu: vdd-cpu { +- compatible = "regulator-fixed"; ++ compatible = "pwm-regulator"; ++ pwms = <&pwm 0 50000 0>; ++ pwm-supply = <®_vcc>; + regulator-name = "vdd-cpu"; +- regulator-min-microvolt = <1100000>; +- regulator-max-microvolt = <1100000>; +- vin-supply = <®_vcc>; ++ regulator-min-microvolt = <810000>; ++ regulator-max-microvolt = <1160000>; + }; + + wifi_pwrseq: wifi-pwrseq { +@@ -52,10 +62,26 @@ + }; + }; + ++&codec { ++ routing = "Headphone Jack", "HPOUTL", ++ "Headphone Jack", "HPOUTR", ++ "LINEINL", "HPOUTL", ++ "LINEINR", "HPOUTR", ++ "MICIN3", "Headset Microphone", ++ "Headset Microphone", "HBIAS"; ++ widgets = "Microphone", "Headset Microphone", ++ "Headphone", "Headphone Jack"; ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_vdd_cpu>; + }; + ++&de { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -73,6 +99,20 @@ + status = "okay"; + }; + ++&hdmi { ++ status = "okay"; ++}; ++ ++&hdmi_out { ++ hdmi_out_connector: endpoint { ++ remote-endpoint = <&hdmi_connector_in>; ++ }; ++}; ++ ++&hdmi_phy { ++ status = "okay"; ++}; ++ + &i2c2 { + pinctrl-0 = <&i2c2_pb0_pins>; + pinctrl-names = "default"; +@@ -90,6 +130,18 @@ + }; + }; + ++&ledc { ++ pinctrl-0 = <&ledc_pc0_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ multi-led@0 { ++ reg = <0x0>; ++ color = ; ++ function = LED_FUNCTION_STATUS; ++ }; ++}; ++ + &lradc { + status = "okay"; + +@@ -142,6 +194,55 @@ + status = "okay"; + }; + ++&pwm { ++ pinctrl-0 = <&pwm0_pd16_pin>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ ++&spi0 { ++ pinctrl-0 = <&spi0_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ flash@0 { ++ compatible = "spi-nand"; ++ reg = <0>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "boot0"; ++ reg = <0x00000000 0x00100000>; ++ }; ++ ++ partition@100000 { ++ label = "uboot"; ++ reg = <0x00100000 0x00300000>; ++ }; ++ ++ partition@400000 { ++ label = "secure_storage"; ++ reg = <0x00400000 0x00100000>; ++ }; ++ ++ partition@500000 { ++ label = "sys"; ++ reg = <0x00500000 0x0fb00000>; ++ }; ++ }; ++ }; ++}; ++ ++&spi1 { ++ pinctrl-0 = <&spi1_pd_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &uart0 { + pinctrl-0 = <&uart0_pb8_pins>; + pinctrl-names = "default"; +--- a/arch/riscv/dts/sun20i-d1.dtsi ++++ b/arch/riscv/dts/sun20i-d1.dtsi +@@ -59,6 +59,35 @@ + #clock-cells = <0>; + }; + ++ thermal-zones { ++ cpu-thermal { ++ polling-delay = <0>; ++ polling-delay-passive = <0>; ++ thermal-sensors = <&ths>; ++ ++ trips { ++ cpu_target: cpu-target { ++ hysteresis = <3000>; ++ temperature = <85000>; ++ type = "passive"; ++ }; ++ ++ cpu-crit { ++ hysteresis = <0>; ++ temperature = <110000>; ++ type = "critical"; ++ }; ++ }; ++ ++ cooling-maps { ++ map0 { ++ trip = <&cpu_target>; ++ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; ++ }; ++ }; ++ }; ++ }; ++ + soc { + compatible = "simple-bus"; + ranges; +@@ -95,6 +124,14 @@ + #interrupt-cells = <3>; + + /omit-if-no-ref/ ++ dsi_4lane_pins: dsi-4lane-pins { ++ pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", ++ "PD6", "PD7", "PD8", "PD9"; ++ drive-strength = <30>; ++ function = "dsi"; ++ }; ++ ++ /omit-if-no-ref/ + i2c0_pb10_pins: i2c0-pb10-pins { + pins = "PB10", "PB11"; + function = "i2c0"; +@@ -116,6 +153,12 @@ + }; + + /omit-if-no-ref/ ++ ledc_pc0_pin: ledc-pc0-pin { ++ pins = "PC0"; ++ function = "ledc"; ++ }; ++ ++ /omit-if-no-ref/ + mmc0_pins: mmc0-pins { + pins = "PF0", "PF1", "PF2", "PF3", "PF4", "PF5"; + function = "mmc0"; +@@ -149,6 +192,48 @@ + }; + + /omit-if-no-ref/ ++ pwm0_pd16_pin: pwm0-pd16-pin { ++ pins = "PD16"; ++ function = "pwm0"; ++ }; ++ ++ /omit-if-no-ref/ ++ pwm2_pd18_pin: pwm2-pd18-pin { ++ pins = "PD18"; ++ function = "pwm2"; ++ }; ++ ++ /omit-if-no-ref/ ++ pwm4_pd20_pin: pwm4-pd20-pin { ++ pins = "PD20"; ++ function = "pwm4"; ++ }; ++ ++ /omit-if-no-ref/ ++ pwm7_pd22_pin: pwm7-pd22-pin { ++ pins = "PD22"; ++ function = "pwm7"; ++ }; ++ ++ /omit-if-no-ref/ ++ spi0_pins: spi0-pins { ++ pins = "PC2", "PC3", "PC4", "PC5", "PC6", "PC7"; ++ function = "spi0"; ++ }; ++ ++ /omit-if-no-ref/ ++ spi1_pb_pins: spi1-pb-pins { ++ pins = "PB0", "PB8", "PB9", "PB10", "PB11", "PB12"; ++ function = "spi1"; ++ }; ++ ++ /omit-if-no-ref/ ++ spi1_pd_pins: spi1-pd-pins { ++ pins = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15"; ++ function = "spi1"; ++ }; ++ ++ /omit-if-no-ref/ + uart0_pb8_pins: uart0-pb8-pins { + pins = "PB8", "PB9"; + function = "uart0"; +@@ -167,6 +252,17 @@ + }; + }; + ++ pwm: pwm@2000c00 { ++ compatible = "allwinner,sun20i-d1-pwm"; ++ reg = <0x2000c00 0x400>; ++ interrupts = <34 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_PWM>, <&osc24M>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_PWM>; ++ status = "disabled"; ++ #pwm-cells = <3>; ++ }; ++ + ccu: clock-controller@2001000 { + compatible = "allwinner,sun20i-d1-ccu"; + reg = <0x2001000 0x1000>; +@@ -178,6 +274,33 @@ + #reset-cells = <1>; + }; + ++ ledc: led-controller@2008000 { ++ compatible = "allwinner,sun20i-d1-ledc", ++ "allwinner,sun50i-a100-ledc"; ++ reg = <0x2008000 0x400>; ++ interrupts = <36 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_LEDC>, <&ccu CLK_LEDC>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_LEDC>; ++ dmas = <&dma 42>; ++ dma-names = "tx"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ ths: temperature-sensor@2009400 { ++ compatible = "allwinner,sun20i-d1-ths"; ++ reg = <0x2009400 0x400>; ++ interrupts = <74 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_THS>, <&osc24M>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_THS>; ++ nvmem-cells = <&ths_calib>; ++ nvmem-cell-names = "calibration"; ++ #thermal-sensor-cells = <0>; ++ }; ++ + lradc: keys@2009800 { + compatible = "allwinner,sun20i-d1-lradc", + "allwinner,sun50i-r329-lradc"; +@@ -188,11 +311,30 @@ + status = "disabled"; + }; + ++ iommu: iommu@2010000 { ++ compatible = "allwinner,sun20i-d1-iommu"; ++ reg = <0x2010000 0x10000>; ++ interrupts = <80 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_IOMMU>; ++ #iommu-cells = <1>; ++ }; ++ + codec: audio-codec@2030000 { +- compatible = "simple-mfd", "syscon"; ++ compatible = "allwinner,sun20i-d1-codec", "simple-mfd", "syscon"; + reg = <0x2030000 0x1000>; ++ interrupts = <41 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_AUDIO>, ++ <&ccu CLK_AUDIO_ADC>, ++ <&ccu CLK_AUDIO_DAC>, ++ <&osc24M>, ++ <&rtc CLK_OSC32K>; ++ clock-names = "bus", "adc", "dac", "hosc", "losc"; ++ resets = <&ccu RST_BUS_AUDIO>; ++ dmas = <&dma 7>, <&dma 7>; ++ dma-names = "rx", "tx"; + #address-cells = <1>; + #size-cells = <1>; ++ #sound-dai-cells = <0>; + + regulators@2030348 { + compatible = "allwinner,sun20i-d1-analog-ldos"; +@@ -208,6 +350,21 @@ + }; + }; + ++ dmic: dmic@2031000 { ++ compatible = "allwinner,sun20i-d1-dmic", ++ "allwinner,sun50i-h6-dmic"; ++ reg = <0x2031000 0x400>; ++ interrupts = <40 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_DMIC>, ++ <&ccu CLK_DMIC>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_DMIC>; ++ dmas = <&dma 8>; ++ dma-names = "rx"; ++ status = "disabled"; ++ #sound-dai-cells = <0>; ++ }; ++ + i2s0: i2s@2032000 { + compatible = "allwinner,sun20i-d1-i2s", + "allwinner,sun50i-r329-i2s"; +@@ -238,6 +395,7 @@ + #sound-dai-cells = <0>; + }; + ++ // TODO: how to integrate ASRC? same or separate node? + i2s2: i2s@2034000 { + compatible = "allwinner,sun20i-d1-i2s", + "allwinner,sun50i-r329-i2s"; +@@ -253,6 +411,22 @@ + #sound-dai-cells = <0>; + }; + ++ // TODO: add receive functionality ++ spdif: spdif@2036000 { ++ compatible = "allwinner,sun20i-d1-spdif"; ++ reg = <0x2036000 0x400>; ++ interrupts = <39 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_SPDIF>, ++ <&ccu CLK_SPDIF_RX>, ++ <&ccu CLK_SPDIF_TX>; ++ clock-names = "apb", "rx", "tx"; ++ resets = <&ccu RST_BUS_SPDIF>; ++ dmas = <&dma 2>, <&dma 2>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ #sound-dai-cells = <0>; ++ }; ++ + timer: timer@2050000 { + compatible = "allwinner,sun20i-d1-timer", + "allwinner,sun8i-a23-timer"; +@@ -457,6 +631,18 @@ + }; + }; + ++ crypto: crypto@3040000 { ++ compatible = "allwinner,sun20i-d1-crypto"; ++ reg = <0x3040000 0x800>; ++ interrupts = <68 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_CE>, ++ <&ccu CLK_CE>, ++ <&ccu CLK_MBUS_CE>, ++ <&rtc CLK_IOSC>; ++ clock-names = "bus", "mod", "ram", "trng"; ++ resets = <&ccu RST_BUS_CE>; ++ }; ++ + mbus: dram-controller@3102000 { + compatible = "allwinner,sun20i-d1-mbus"; + reg = <0x3102000 0x1000>, +@@ -525,6 +711,39 @@ + #size-cells = <0>; + }; + ++ spi0: spi@4025000 { ++ compatible = "allwinner,sun20i-d1-spi", ++ "allwinner,sun50i-r329-spi"; ++ reg = <0x4025000 0x1000>; ++ interrupts = <31 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; ++ clock-names = "ahb", "mod"; ++ resets = <&ccu RST_BUS_SPI0>; ++ dmas = <&dma 22>, <&dma 22>; ++ dma-names = "rx", "tx"; ++ num-cs = <1>; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ ++ spi1: spi@4026000 { ++ compatible = "allwinner,sun20i-d1-spi-dbi", ++ "allwinner,sun50i-r329-spi-dbi", ++ "allwinner,sun50i-r329-spi"; ++ reg = <0x4026000 0x1000>; ++ interrupts = <32 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_SPI1>, <&ccu CLK_SPI1>; ++ clock-names = "ahb", "mod"; ++ resets = <&ccu RST_BUS_SPI1>; ++ dmas = <&dma 23>, <&dma 23>; ++ dma-names = "rx", "tx"; ++ num-cs = <1>; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ + usb_otg: usb@4100000 { + compatible = "allwinner,sun20i-d1-musb", + "allwinner,sun8i-a33-musb"; +@@ -653,6 +872,7 @@ + <&display_clocks CLK_MIXER0>; + clock-names = "bus", "mod"; + resets = <&display_clocks RST_MIXER0>; ++ iommus = <&iommu 2>; + + ports { + #address-cells = <1>; +@@ -675,6 +895,7 @@ + <&display_clocks CLK_MIXER1>; + clock-names = "bus", "mod"; + resets = <&display_clocks RST_MIXER1>; ++ iommus = <&iommu 2>; + + ports { + #address-cells = <1>; +@@ -690,6 +911,40 @@ + }; + }; + ++ dsi: dsi@5450000 { ++ compatible = "allwinner,sun20i-d1-mipi-dsi", ++ "allwinner,sun50i-a100-mipi-dsi"; ++ reg = <0x5450000 0x1000>; ++ interrupts = <108 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_MIPI_DSI>, ++ <&tcon_top CLK_TCON_TOP_DSI>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_MIPI_DSI>; ++ phys = <&dphy>; ++ phy-names = "dphy"; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ port { ++ dsi_in_tcon_lcd0: endpoint { ++ remote-endpoint = <&tcon_lcd0_out_dsi>; ++ }; ++ }; ++ }; ++ ++ dphy: phy@5451000 { ++ compatible = "allwinner,sun20i-d1-mipi-dphy", ++ "allwinner,sun50i-a100-mipi-dphy"; ++ reg = <0x5451000 0x1000>; ++ interrupts = <108 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_MIPI_DSI>, ++ <&ccu CLK_MIPI_DSI>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_MIPI_DSI>; ++ #phy-cells = <0>; ++ }; ++ + tcon_top: tcon-top@5460000 { + compatible = "allwinner,sun20i-d1-tcon-top"; + reg = <0x5460000 0x1000>; +@@ -770,6 +1025,10 @@ + + tcon_top_hdmi_out: port@5 { + reg = <5>; ++ ++ tcon_top_hdmi_out_hdmi: endpoint { ++ remote-endpoint = <&hdmi_in_tcon_top>; ++ }; + }; + }; + }; +@@ -785,6 +1044,8 @@ + resets = <&ccu RST_BUS_TCON_LCD0>, + <&ccu RST_BUS_LVDS0>; + reset-names = "lcd", "lvds"; ++ phys = <&dphy>; ++ phy-names = "lvds0"; + #clock-cells = <0>; + + ports { +@@ -809,6 +1070,13 @@ + + tcon_lcd0_out: port@1 { + reg = <1>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ tcon_lcd0_out_dsi: endpoint@1 { ++ reg = <1>; ++ remote-endpoint = <&dsi_in_tcon_lcd0>; ++ }; + }; + }; + }; +@@ -853,6 +1121,50 @@ + }; + }; + ++ hdmi: hdmi@5500000 { ++ compatible = "allwinner,sun20i-d1-dw-hdmi"; ++ reg = <0x5500000 0x10000>; ++ reg-io-width = <1>; ++ interrupts = <109 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ccu CLK_BUS_HDMI>, ++ <&ccu CLK_HDMI_24M>, ++ <&ccu CLK_HDMI_CEC>; ++ clock-names = "iahb", "isfr", "cec"; ++ resets = <&ccu RST_BUS_HDMI_SUB>; ++ reset-names = "ctrl"; ++ phys = <&hdmi_phy>; ++ phy-names = "phy"; ++ status = "disabled"; ++ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ port@0 { ++ reg = <0>; ++ ++ hdmi_in_tcon_top: endpoint { ++ remote-endpoint = <&tcon_top_hdmi_out_hdmi>; ++ }; ++ }; ++ ++ hdmi_out: port@1 { ++ reg = <1>; ++ }; ++ }; ++ }; ++ ++ hdmi_phy: phy@5510000 { ++ compatible = "allwinner,sun20i-d1-hdmi-phy"; ++ reg = <0x5510000 0x10000>; ++ clocks = <&ccu CLK_BUS_HDMI>, <&ccu CLK_HDMI_24M>; ++ clock-names = "bus", "mod"; ++ resets = <&ccu RST_BUS_HDMI_MAIN>; ++ reset-names = "phy"; ++ status = "disabled"; ++ #phy-cells = <0>; ++ }; ++ + riscv_wdt: watchdog@6011000 { + compatible = "allwinner,sun20i-d1-wdt"; + reg = <0x6011000 0x20>; diff --git a/package/boot/uboot-d1/patches/0089-sunxi-riscv-Add-defconfigs-for-several-boards.patch b/package/boot/uboot-d1/patches/0089-sunxi-riscv-Add-defconfigs-for-several-boards.patch new file mode 100644 index 00000000000000..a1c2ac9ad90d92 --- /dev/null +++ b/package/boot/uboot-d1/patches/0089-sunxi-riscv-Add-defconfigs-for-several-boards.patch @@ -0,0 +1,108 @@ +From 0a4e7a1a19dd505bc5b6ff887b2ce39983aaa92d Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 31 Oct 2022 23:27:08 -0500 +Subject: [PATCH 89/90] sunxi: riscv: Add defconfigs for several boards + +Signed-off-by: Samuel Holland +--- + configs/devterm_r_01_defconfig | 10 ++++++++++ + configs/dongshan_nezha_stu_defconfig | 13 +++++++++++++ + configs/lichee_rv_86_panel_defconfig | 13 +++++++++++++ + configs/lichee_rv_dock_defconfig | 10 ++++++++++ + configs/mangopi_mq_pro_defconfig | 10 ++++++++++ + configs/nezha_defconfig | 13 +++++++++++++ + 6 files changed, 69 insertions(+) + create mode 100644 configs/devterm_r_01_defconfig + create mode 100644 configs/dongshan_nezha_stu_defconfig + create mode 100644 configs/lichee_rv_86_panel_defconfig + create mode 100644 configs/lichee_rv_dock_defconfig + create mode 100644 configs/mangopi_mq_pro_defconfig + create mode 100644 configs/nezha_defconfig + +--- /dev/null ++++ b/configs/devterm_r_01_defconfig +@@ -0,0 +1,10 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-devterm-v3.14" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_DM_REGULATOR_FIXED=y +--- /dev/null ++++ b/configs/dongshan_nezha_stu_defconfig +@@ -0,0 +1,13 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-dongshan-nezha-stu" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++CONFIG_NET_RANDOM_ETHADDR=y ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_PHY_REALTEK=y ++CONFIG_SUN8I_EMAC=y ++CONFIG_DM_REGULATOR_FIXED=y +--- /dev/null ++++ b/configs/lichee_rv_86_panel_defconfig +@@ -0,0 +1,13 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-lichee-rv-86-panel-480p" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++CONFIG_NET_RANDOM_ETHADDR=y ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_PHY_REALTEK=y ++CONFIG_SUN8I_EMAC=y ++CONFIG_DM_REGULATOR_FIXED=y +--- /dev/null ++++ b/configs/lichee_rv_dock_defconfig +@@ -0,0 +1,10 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-lichee-rv-dock" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_DM_REGULATOR_FIXED=y +--- /dev/null ++++ b/configs/mangopi_mq_pro_defconfig +@@ -0,0 +1,10 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-mangopi-mq-pro" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_DM_REGULATOR_FIXED=y +--- /dev/null ++++ b/configs/nezha_defconfig +@@ -0,0 +1,13 @@ ++CONFIG_RISCV=y ++CONFIG_DEFAULT_DEVICE_TREE="sun20i-d1-nezha" ++CONFIG_TARGET_SUN20I_D1=y ++CONFIG_ARCH_RV64I=y ++CONFIG_RISCV_SMODE=y ++# CONFIG_SPL_SMP is not set ++CONFIG_SYS_SPL_MALLOC=y ++CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0 ++CONFIG_NET_RANDOM_ETHADDR=y ++# CONFIG_SYS_I2C_MVTWSI is not set ++CONFIG_PHY_REALTEK=y ++CONFIG_SUN8I_EMAC=y ++CONFIG_DM_REGULATOR_FIXED=y diff --git a/package/boot/uboot-d1/patches/0090-drivers-phy-fix-typo.patch b/package/boot/uboot-d1/patches/0090-drivers-phy-fix-typo.patch new file mode 100644 index 00000000000000..c9c3b9b959e8d5 --- /dev/null +++ b/package/boot/uboot-d1/patches/0090-drivers-phy-fix-typo.patch @@ -0,0 +1,21 @@ +From 62419798c137c9eec2d2c1011e417d1520aecffb Mon Sep 17 00:00:00 2001 +From: Zoltan HERPAI +Date: Tue, 6 Jun 2023 19:46:30 +0000 +Subject: [PATCH 90/90] drivers: phy: fix typo + +Signed-off-by: Zoltan HERPAI +--- + drivers/phy/allwinner/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/phy/allwinner/Kconfig ++++ b/drivers/phy/allwinner/Kconfig +@@ -3,7 +3,7 @@ + # + config PHY_SUN4I_USB + bool "Allwinner Sun4I USB PHY driver" +- depends on depends on BOARD_SUNXI ++ depends on BOARD_SUNXI + default y + select DM_REGULATOR + select PHY diff --git a/package/boot/uboot-d1/patches/100-mkimage-check-environment-for-dtc-binary-location.patch b/package/boot/uboot-d1/patches/100-mkimage-check-environment-for-dtc-binary-location.patch new file mode 100644 index 00000000000000..789172f21b41e3 --- /dev/null +++ b/package/boot/uboot-d1/patches/100-mkimage-check-environment-for-dtc-binary-location.patch @@ -0,0 +1,35 @@ +From 637800493945ffed2f454756300437a4ec86e3b1 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Wed, 19 Jul 2017 22:23:15 +0200 +Subject: mkimage: check environment for dtc binary location + +Currently mkimage assumes the dtc binary is in the path and fails +otherwise. This patch makes it check the DTC environment variable first +for the dtc binary and then fall back to the default path. This makes +it possible to call the u-boot build with make DTC=... and build a fit +image with the dtc binary not being the the default path. + +Signed-off-by: Hauke Mehrtens +Cc: Simon Glass +--- + tools/fit_image.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/tools/fit_image.c ++++ b/tools/fit_image.c +@@ -729,9 +729,14 @@ static int fit_handle_file(struct image_ + } + *cmd = '\0'; + } else if (params->datafile) { ++ const char* dtc = getenv("DTC"); ++ ++ if (!dtc) ++ dtc = MKIMAGE_DTC; ++ + /* dtc -I dts -O dtb -p 500 -o tmpfile datafile */ + snprintf(cmd, sizeof(cmd), "%s %s -o \"%s\" \"%s\"", +- MKIMAGE_DTC, params->dtc, tmpfile, params->datafile); ++ dtc, params->dtc, tmpfile, params->datafile); + debug("Trying to execute \"%s\"\n", cmd); + } else { + snprintf(cmd, sizeof(cmd), "cp \"%s\" \"%s\"", diff --git a/package/boot/uboot-d1/patches/130-fix-mkimage-host-build.patch b/package/boot/uboot-d1/patches/130-fix-mkimage-host-build.patch new file mode 100644 index 00000000000000..cd65c1321fc320 --- /dev/null +++ b/package/boot/uboot-d1/patches/130-fix-mkimage-host-build.patch @@ -0,0 +1,24 @@ +--- a/tools/image-host.c ++++ b/tools/image-host.c +@@ -1125,6 +1125,7 @@ static int fit_config_add_verification_d + * 2) get public key (X509_get_pubkey) + * 3) provide der format (d2i_RSAPublicKey) + */ ++#ifdef CONFIG_TOOLS_LIBCRYPTO + static int read_pub_key(const char *keydir, const void *name, + unsigned char **pubkey, int *pubkey_len) + { +@@ -1178,6 +1179,13 @@ err_cert: + fclose(f); + return ret; + } ++#else ++static int read_pub_key(const char *keydir, const void *name, ++ unsigned char **pubkey, int *pubkey_len) ++{ ++ return -ENOSYS; ++} ++#endif + + int fit_pre_load_data(const char *keydir, void *keydest, void *fit) + { diff --git a/package/boot/uboot-d1/patches/211-no-kwbimage.patch b/package/boot/uboot-d1/patches/211-no-kwbimage.patch new file mode 100644 index 00000000000000..65d14f5bece8bd --- /dev/null +++ b/package/boot/uboot-d1/patches/211-no-kwbimage.patch @@ -0,0 +1,10 @@ +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -119,7 +119,6 @@ dumpimage-mkimage-objs := aisimage.o \ + imximage.o \ + imx8image.o \ + imx8mimage.o \ +- kwbimage.o \ + lib/md5.o \ + lpc32xximage.o \ + mxsimage.o \ diff --git a/package/boot/uboot-d1/patches/300-force-pylibfdt-build.patch b/package/boot/uboot-d1/patches/300-force-pylibfdt-build.patch new file mode 100644 index 00000000000000..e2312eaa5a59f9 --- /dev/null +++ b/package/boot/uboot-d1/patches/300-force-pylibfdt-build.patch @@ -0,0 +1,30 @@ +--- a/Makefile ++++ b/Makefile +@@ -2045,26 +2045,7 @@ endif + # Check dtc and pylibfdt, if DTC is provided, else build them + PHONY += scripts_dtc + scripts_dtc: scripts_basic +- $(Q)if test "$(DTC)" = "$(DTC_INTREE)"; then \ +- $(MAKE) $(build)=scripts/dtc; \ +- else \ +- if ! $(DTC) -v >/dev/null; then \ +- echo '*** Failed to check dtc version: $(DTC)'; \ +- false; \ +- else \ +- if test "$(call dtc-version)" -lt $(DTC_MIN_VERSION); then \ +- echo '*** Your dtc is too old, please upgrade to dtc $(DTC_MIN_VERSION) or newer'; \ +- false; \ +- else \ +- if [ -n "$(CONFIG_PYLIBFDT)" ]; then \ +- if ! echo "import libfdt" | $(PYTHON3) 2>/dev/null; then \ +- echo '*** pylibfdt does not seem to be available with $(PYTHON3)'; \ +- false; \ +- fi; \ +- fi; \ +- fi; \ +- fi; \ +- fi ++ $(MAKE) $(build)=scripts/dtc + + # --------------------------------------------------------------------------- + quiet_cmd_cpp_lds = LDS $@ diff --git a/package/boot/uboot-d1/uEnv-default.txt b/package/boot/uboot-d1/uEnv-default.txt new file mode 100644 index 00000000000000..4f6f5fa172f69b --- /dev/null +++ b/package/boot/uboot-d1/uEnv-default.txt @@ -0,0 +1,4 @@ +setenv loadkernel fatload mmc 0:1 \$kernel_addr_r Image +setenv bootargs console=ttyS0,115200 earlycon=sbi root=/dev/mmcblk0p2 rootwait +setenv uenvcmd run loadkernel \&\& booti \$kernel_addr_r - \$fdtcontroladdr +run uenvcmd diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile index 9647b38385308f..00aa4241625f52 100644 --- a/package/boot/uboot-envtools/Makefile +++ b/package/boot/uboot-envtools/Makefile @@ -9,15 +9,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=uboot-envtools PKG_DISTNAME:=u-boot -PKG_VERSION:=2023.07.02 -PKG_RELEASE:=3 +PKG_VERSION:=2024.01 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:= \ https://ftp.denx.de/pub/u-boot \ https://mirror.cyberbits.eu/u-boot \ ftp://ftp.denx.de/pub/u-boot -PKG_HASH:=6b6a48581c14abb0f95bd87c1af4d740922406d7b801002a9f94727fdde021d5 +PKG_HASH:=b99611f1ed237bf3541bdc8434b68c96a6e05967061f992443cb30aabebef5b3 PKG_SOURCE_SUBDIR:=$(PKG_DISTNAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_DISTNAME)-$(PKG_VERSION) diff --git a/package/boot/uboot-envtools/files/ipq40xx b/package/boot/uboot-envtools/files/ipq40xx index 8d993fae3668b3..8cada7334b326d 100644 --- a/package/boot/uboot-envtools/files/ipq40xx +++ b/package/boot/uboot-envtools/files/ipq40xx @@ -53,7 +53,8 @@ aruba,ap-303) aruba,ap-365) ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000" ;; -buffalo,wtr-m2133hp) +buffalo,wtr-m2133hp|\ +netgear,lbr20) ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000" ;; linksys,ea6350v3) diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 7bbeb2fd5dcfa3..08d2bf782bdb1f 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -11,53 +11,62 @@ touch /etc/config/ubootenv board=$(board_name) +ubootenv_add_mmc_default() { + local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")" + ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1" + ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1" +} + +ubootenv_add_nor_default() { + local envdev="/dev/mtd$(find_mtd_index "u-boot-env")" + ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1" + ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1" +} + +ubootenv_add_ubi_default() { + . /lib/upgrade/nand.sh + local envubi=$(nand_find_ubi ubi) + local envdev=/dev/$(nand_find_volume $envubi ubootenv) + local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) + ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1" +} + case "$board" in asus,rt-ax59u) ubootenv_add_uci_config "/dev/mtd0" "0x100000" "0x20000" "0x20000" ;; bananapi,bpi-r3|\ -bananapi,bpi-r3-mini) - rootdev="$(cmdline_get_var root)" - rootdev="${rootdev##*/}" - rootdev="${rootdev%%p[0-9]*}" - case "$rootdev" in +bananapi,bpi-r3-mini|\ +bananapi,bpi-r4) + . /lib/upgrade/common.sh + + bootdev="$(fitblk_get_bootdev)" + case "$bootdev" in + ubi*) + ubootenv_add_ubi_default + ;; mmc*) - local envdev=$(find_mmc_part "ubootenv" $rootdev) - ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1" - ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1" + ubootenv_add_mmc_default "${bootdev%%p[0-9]*}" ;; mtd*) - local envdev=/dev/mtd$(find_mtd_index "u-boot-env") - ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1" - ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1" - ;; - ubi*) - . /lib/upgrade/nand.sh - local envubi=$(nand_find_ubi ubi) - local envdev=/dev/$(nand_find_volume $envubi ubootenv) - local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) - ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1" - ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_nor_default ;; esac ;; cmcc,rax3000m) case "$(cmdline_get_var root)" in /dev/mmc*) - local envdev=$(find_mmc_part "ubootenv" "mmcblk0") - ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1" - ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1" + ubootenv_add_mmc_default ;; *) - . /lib/upgrade/nand.sh - local envubi=$(nand_find_ubi ubi) - local envdev=/dev/$(nand_find_volume $envubi ubootenv) - local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) - ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1" - ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_ubi_default ;; esac ;; +comfast,cf-e393ax) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000" + ;; cetron,ct3003|\ netgear,wax220|\ zbtlink,zbt-z8102ax|\ @@ -72,13 +81,9 @@ tplink,tl-xdr6086|\ tplink,tl-xdr6088|\ xiaomi,mi-router-ax3000t-ubootmod|\ xiaomi,mi-router-wr30u-ubootmod|\ -xiaomi,redmi-router-ax6000-ubootmod) - . /lib/upgrade/nand.sh - local envubi=$(nand_find_ubi ubi) - local envdev=/dev/$(nand_find_volume $envubi ubootenv) - local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) - ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1" - ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1" +xiaomi,redmi-router-ax6000-ubootmod|\ +zyxel,ex5601-t0-ubootmod) + ubootenv_add_ubi_default ;; glinet,gl-mt2500|\ glinet,gl-mt6000) @@ -111,14 +116,6 @@ zyxel,ex5601-t0) local envdev=/dev/mtd$(find_mtd_index "u-boot-env") ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2" ;; -zyxel,ex5601-t0-ubootmod) - . /lib/upgrade/nand.sh - local envubi=$(nand_find_ubi ubi) - local envdev=/dev/$(nand_find_volume $envubi ubootenv) - local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) - ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1" - ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1" - ;; zyxel,ex5700-telenor) ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1" ;; diff --git a/package/boot/uboot-envtools/files/mediatek_mt7622 b/package/boot/uboot-envtools/files/mediatek_mt7622 index fdf0d331fc569b..c8d385748449f3 100644 --- a/package/boot/uboot-envtools/files/mediatek_mt7622 +++ b/package/boot/uboot-envtools/files/mediatek_mt7622 @@ -9,6 +9,21 @@ touch /etc/config/ubootenv . /lib/uboot-envtools.sh . /lib/functions.sh +ubootenv_add_mmc_default() { + local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")" + ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1" + ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1" +} + +ubootenv_add_ubi_default() { + . /lib/upgrade/nand.sh + local envubi=$(nand_find_ubi ubi) + local envdev=/dev/$(nand_find_volume $envubi ubootenv) + local envdev2=/dev/$(nand_find_volume $envubi ubootenv2) + ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1" +} + board=$(board_name) case "$board" in @@ -17,22 +32,17 @@ dlink,eagle-pro-ai-r32-a1) ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x2000" "0x2000" ;; linksys,e8450-ubi) - ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1" - ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_ubi_default ;; bananapi,bpi-r64) - rootdev="$(cmdline_get_var root)" - rootdev="${rootdev##*/}" - rootdev="${rootdev%%p[0-9]*}" - case "$rootdev" in + . /lib/upgrade/common.sh + bootdev="$(fitblk_get_bootdev)" + case "$bootdev" in mmc*) - local envdev=$(find_mmc_part "ubootenv" $rootdev) - ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1" - ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1" + ubootenv_add_mmc_default "${bootdev%p[0-9]*}" ;; ubi*) - ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1" - ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1" + ubootenv_add_ubi_default ;; esac ;; @@ -42,8 +52,10 @@ buffalo,wsr-2533dhp2) ruijie,rg-ew3200gx-pro) ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x20000" "0x20000" ;; -ubnt,unifi-6-lr-ubootmod) - ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x1000" +ubnt,unifi-6-lr-v1-ubootmod|\ +ubnt,unifi-6-lr-v2-ubootmod|\ +ubnt,unifi-6-lr-v3-ubootmod) + ubootenv_add_uci_config "/dev/mtd$(find_mtd_index "u-boot-env")" "0x0" "0x4000" "0x1000" ;; xiaomi,redmi-router-ax6s) ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x40000" diff --git a/package/boot/uboot-envtools/files/mediatek_mt7623 b/package/boot/uboot-envtools/files/mediatek_mt7623 index fd2a01006a8e08..008aff57853c6d 100644 --- a/package/boot/uboot-envtools/files/mediatek_mt7623 +++ b/package/boot/uboot-envtools/files/mediatek_mt7623 @@ -14,9 +14,8 @@ board=$(board_name) case "$board" in bananapi,bpi-r2) . /lib/upgrade/common.sh - export_bootdevice - export_partdevice ubootpart 1 - ubootenv_add_uci_config "/dev/$ubootpart" "0xb0000" "0x10000" "0x10000" "1" + bootdev="$(fitblk_get_bootdev)" + ubootenv_add_uci_config "/dev/${bootdev%p[0-9]*}p1" "0xb0000" "0x10000" "0x10000" "1" ;; unielec,u7623-02) ubootenv_add_uci_config "/dev/mmcblk0p1" "0xc0000" "0x10000" "0x10000" "1" diff --git a/package/boot/uboot-envtools/files/qualcommax_ipq60xx b/package/boot/uboot-envtools/files/qualcommax_ipq60xx new file mode 100644 index 00000000000000..df19a3033577b2 --- /dev/null +++ b/package/boot/uboot-envtools/files/qualcommax_ipq60xx @@ -0,0 +1,22 @@ +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(board_name) + +case "$board" in +8devices,mango-dvk|\ +8devices,mango-dvk-sfp) + idx="$(find_mtd_index 0:APPSBLENV)" + [ -n "$idx" ] && \ + ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config + +exit 0 diff --git a/package/boot/uboot-envtools/files/qualcommax_ipq807x b/package/boot/uboot-envtools/files/qualcommax_ipq807x index bcedfd9adc91ce..86e7062cfc3f47 100644 --- a/package/boot/uboot-envtools/files/qualcommax_ipq807x +++ b/package/boot/uboot-envtools/files/qualcommax_ipq807x @@ -30,7 +30,8 @@ edimax,cax1800) ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x20000" ;; linksys,mx4200v1|\ -linksys,mx4200v2) +linksys,mx4200v2|\ +linksys,mx5300) idx="$(find_mtd_index u_env)" [ -n "$idx" ] && \ ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x40000" "0x20000" "2" diff --git a/package/boot/uboot-envtools/patches/002-Revert-tools-env-use-run-to-store-lockfile.patch b/package/boot/uboot-envtools/patches/002-Revert-tools-env-use-run-to-store-lockfile.patch index ace7cdc68107e7..e843e4252bb430 100644 --- a/package/boot/uboot-envtools/patches/002-Revert-tools-env-use-run-to-store-lockfile.patch +++ b/package/boot/uboot-envtools/patches/002-Revert-tools-env-use-run-to-store-lockfile.patch @@ -10,8 +10,6 @@ This reverts upstream commit tools/env/fw_env_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c -index 0b201b9e62..1d193bd437 100644 --- a/tools/env/fw_env_main.c +++ b/tools/env/fw_env_main.c @@ -73,7 +73,7 @@ void usage_printenv(void) @@ -32,7 +30,7 @@ index 0b201b9e62..1d193bd437 100644 " -s, --script batch mode to minimize writes\n" "\n" "Examples:\n" -@@ -206,7 +206,7 @@ int parse_setenv_args(int argc, char *argv[]) +@@ -206,7 +206,7 @@ int parse_setenv_args(int argc, char *ar int main(int argc, char *argv[]) { @@ -41,4 +39,3 @@ index 0b201b9e62..1d193bd437 100644 int lockfd = -1; int retval = EXIT_SUCCESS; char *_cmdname; - diff --git a/package/boot/uboot-envtools/patches/011-fw_env-keep-calling-read-until-whole-flash-block-is-.patch b/package/boot/uboot-envtools/patches/011-fw_env-keep-calling-read-until-whole-flash-block-is-.patch new file mode 100644 index 00000000000000..af1c32fe91cb9f --- /dev/null +++ b/package/boot/uboot-envtools/patches/011-fw_env-keep-calling-read-until-whole-flash-block-is-.patch @@ -0,0 +1,75 @@ +From 9e3003f79d168eac7ee65cd457e3904e2fb4eea8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Wed, 13 Dec 2023 13:13:54 +0100 +Subject: [PATCH] fw_env: keep calling read() until whole flash block is read +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It's totally valid for read() to provide less bytes than requested +maximum. It may happen if there is no more data available yet or source +pushes data in small chunks. + +This actually happens when trying to read env data from NVMEM device. +Kernel may provide NVMEM content in page size parts (like 4096 B). + +This fixes warnings like: +Warning on /sys/bus/nvmem/devices/u-boot-env0/nvmem: Attempted to read 16384 bytes but got 4096 +Warning on /sys/bus/nvmem/devices/u-boot-env0/nvmem: Attempted to read 12288 bytes but got 4096 +Warning on /sys/bus/nvmem/devices/u-boot-env0/nvmem: Attempted to read 8192 bytes but got 4096 + +Since the main loop in flash_read_buf() is used to read blocks this +patch adds a new nested one. + +Signed-off-by: Rafał Miłecki +--- + tools/env/fw_env.c | 34 +++++++++++++++------------------- + 1 file changed, 15 insertions(+), 19 deletions(-) + +--- a/tools/env/fw_env.c ++++ b/tools/env/fw_env.c +@@ -948,29 +948,25 @@ static int flash_read_buf(int dev, int f + */ + lseek(fd, blockstart + block_seek, SEEK_SET); + +- rc = read(fd, buf + processed, readlen); +- if (rc == -1) { +- fprintf(stderr, "Read error on %s: %s\n", +- DEVNAME(dev), strerror(errno)); +- return -1; +- } ++ while (readlen) { ++ rc = read(fd, buf + processed, readlen); ++ if (rc == -1) { ++ fprintf(stderr, "Read error on %s: %s\n", ++ DEVNAME(dev), strerror(errno)); ++ return -1; ++ } + #ifdef DEBUG +- fprintf(stderr, "Read 0x%x bytes at 0x%llx on %s\n", +- rc, (unsigned long long)blockstart + block_seek, +- DEVNAME(dev)); ++ fprintf(stderr, "Read 0x%x bytes at 0x%llx on %s\n", ++ rc, (unsigned long long)blockstart + block_seek, ++ DEVNAME(dev)); + #endif +- processed += rc; +- if (rc != readlen) { +- fprintf(stderr, +- "Warning on %s: Attempted to read %zd bytes but got %d\n", +- DEVNAME(dev), readlen, rc); ++ processed += rc; + readlen -= rc; +- block_seek += rc; +- } else { +- blockstart += blocklen; +- readlen = min(blocklen, count - processed); +- block_seek = 0; + } ++ ++ blockstart += blocklen; ++ readlen = min(blocklen, count - processed); ++ block_seek = 0; + } + + return processed; diff --git a/package/boot/uboot-envtools/patches/012-fw_env-autodetect-NAND-erase-size-and-env-sectors.patch b/package/boot/uboot-envtools/patches/012-fw_env-autodetect-NAND-erase-size-and-env-sectors.patch new file mode 100644 index 00000000000000..78f555fb1f3aed --- /dev/null +++ b/package/boot/uboot-envtools/patches/012-fw_env-autodetect-NAND-erase-size-and-env-sectors.patch @@ -0,0 +1,49 @@ +From d73a6641868029b5cae53ed00c5766921c9d8b1f Mon Sep 17 00:00:00 2001 +From: Anthony Loiseau +Date: Thu, 21 Dec 2023 23:44:38 +0100 +Subject: [PATCH] fw_env: autodetect NAND erase size and env sectors + +As already done for NOR chips, if device ESIZE and ENVSECTORS static +configurations are both zero, then autodetect them at runtime. + +Cc: Joe Hershberger +cc: Stefan Agner +cc: Rasmus Villemoes +Signed-off-by: Anthony Loiseau +--- + tools/env/README | 3 +++ + tools/env/fw_env.c | 11 +++++++++-- + 2 files changed, 12 insertions(+), 2 deletions(-) + +--- a/tools/env/README ++++ b/tools/env/README +@@ -58,6 +58,9 @@ DEVICEx_ENVSECTORS defines the number of + this environment instance. On NAND this is used to limit the range + within which bad blocks are skipped, on NOR it is not used. + ++If DEVICEx_ESIZE and DEVICEx_ENVSECTORS are both zero, then a runtime ++detection is attempted for NOR and NAND mtd types. ++ + To prevent losing changes to the environment and to prevent confusing the MTD + drivers, a lock file at /run/fw_printenv.lock is used to serialize access + to the environment. +--- a/tools/env/fw_env.c ++++ b/tools/env/fw_env.c +@@ -1655,8 +1655,15 @@ static int check_device_config(int dev) + } + DEVTYPE(dev) = mtdinfo.type; + if (DEVESIZE(dev) == 0 && ENVSECTORS(dev) == 0 && +- mtdinfo.type == MTD_NORFLASH) +- DEVESIZE(dev) = mtdinfo.erasesize; ++ mtdinfo.erasesize > 0) { ++ if (mtdinfo.type == MTD_NORFLASH) ++ DEVESIZE(dev) = mtdinfo.erasesize; ++ else if (mtdinfo.type == MTD_NANDFLASH) { ++ DEVESIZE(dev) = mtdinfo.erasesize; ++ ENVSECTORS(dev) = ++ mtdinfo.size / mtdinfo.erasesize; ++ } ++ } + if (DEVESIZE(dev) == 0) + /* Assume the erase size is the same as the env-size */ + DEVESIZE(dev) = ENVSIZE(dev); diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index c4f4e8c2d746fa..810f4d3a861159 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk -PKG_VERSION:=2023.07.02 -PKG_HASH:=6b6a48581c14abb0f95bd87c1af4d740922406d7b801002a9f94727fdde021d5 +PKG_VERSION:=2024.01 +PKG_HASH:=b99611f1ed237bf3541bdc8434b68c96a6e05967061f992443cb30aabebef5b3 PKG_BUILD_DEPENDS:=!(TARGET_ramips||TARGET_mediatek_mt7623):arm-trusted-firmware-tools/host UBOOT_USE_INTREE_DTC:=1 @@ -75,6 +75,15 @@ define U-Boot/mt7621_nand_rfb UBOOT_IMAGE:=u-boot-mt7621.bin endef +define U-Boot/mt7621_zbtlink_zbt-wg3526-16m + NAME:=Zbtlink ZBT-WG3526-16m + UBOOT_CONFIG:=mt7621_zbtlink_zbt-wg3526-16m + BUILD_DEVICES:=zbtlink_zbt-wg3526-16m + BUILD_TARGET:=ramips + BUILD_SUBTARGET:=mt7621 + UBOOT_IMAGE:=u-boot-mt7621.bin +endef + define U-Boot/mt7622_rfb1 NAME:=MT7622 Reference Board 1 UBOOT_CONFIG:=mt7622_rfb @@ -88,9 +97,9 @@ define U-Boot/mt7622_linksys_e8450 BUILD_DEVICES:=linksys_e8450-ubi BUILD_SUBTARGET:=mt7622 UBOOT_IMAGE:=u-boot.fip - BL2_BOOTDEV:=snand + BL2_BOOTDEV:=snand-ubi BL2_DDRBLOB:=1 - DEPENDS:=+trusted-firmware-a-mt7622-snand-1ddr + DEPENDS:=+trusted-firmware-a-mt7622-snand-ubi-1ddr endef define U-Boot/mt7622_bananapi_bpi-r64-emmc @@ -121,9 +130,9 @@ define U-Boot/mt7622_bananapi_bpi-r64-snand BUILD_DEVICES:=bananapi_bpi-r64 BUILD_SUBTARGET:=mt7622 UBOOT_IMAGE:=u-boot.fip - BL2_BOOTDEV:=snand + BL2_BOOTDEV:=snand-ubi BL2_DDRBLOB:=2 - DEPENDS:=+trusted-firmware-a-mt7622-snand-2ddr + DEPENDS:=+trusted-firmware-a-mt7622-snand-ubi-2ddr endef define U-Boot/mt7622_ubnt_unifi-6-lr-v1 @@ -186,7 +195,7 @@ define U-Boot/mt7628_rfb UBOOT_IMAGE:=u-boot-with-spl.bin endef -define U-Boot/ravpower_rp-wd009 +define U-Boot/mt7628_ravpower_rp-wd009 NAME:=RAVPower RP-WD009 BUILD_TARGET:=ramips BUILD_DEVICES:=ravpower_rp-wd009 @@ -388,10 +397,10 @@ define U-Boot/mt7986_bananapi_bpi-r3-snand BUILD_DEVICES:=bananapi_bpi-r3 UBOOT_CONFIG:=mt7986a_bpi-r3-snand UBOOT_IMAGE:=u-boot.fip - BL2_BOOTDEV:=spim-nand + BL2_BOOTDEV:=spim-nand-ubi BL2_SOC:=mt7986 BL2_DDRTYPE:=ddr4 - DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-ddr4 + DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-ubi-ddr4 endef define U-Boot/mt7986_bananapi_bpi-r3-nor @@ -408,7 +417,7 @@ define U-Boot/mt7986_bananapi_bpi-r3-nor endef define U-Boot/mt7986_bananapi_bpi-r3-mini-emmc - NAME:=BananaPi BPi-R3 mini + NAME:=BananaPi BPi-R3 Mini BUILD_SUBTARGET:=filogic BUILD_DEVICES:=bananapi_bpi-r3-mini UBOOT_CONFIG:=mt7986a_bpi-r3-mini-emmc @@ -420,15 +429,15 @@ define U-Boot/mt7986_bananapi_bpi-r3-mini-emmc endef define U-Boot/mt7986_bananapi_bpi-r3-mini-snand - NAME:=BananaPi BPi-R3 mini + NAME:=BananaPi BPi-R3 Mini BUILD_SUBTARGET:=filogic BUILD_DEVICES:=bananapi_bpi-r3-mini UBOOT_CONFIG:=mt7986a_bpi-r3-mini-snand UBOOT_IMAGE:=u-boot.fip - BL2_BOOTDEV:=spim-nand + BL2_BOOTDEV:=spim-nand-ubi BL2_SOC:=mt7986 BL2_DDRTYPE:=ddr4 - DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-ddr4 + DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-ubi-ddr4 endef define U-Boot/mt7986_glinet_gl-mt6000 @@ -515,6 +524,42 @@ define U-Boot/mt7986_zyxel_ex5601-t0 DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-4k-ddr4 endef +define U-Boot/mt7988_bananapi_bpi-r4-emmc + NAME:=BananaPi BPi-R4 + BUILD_SUBTARGET:=filogic + BUILD_DEVICES:=bananapi_bpi-r4 + UBOOT_CONFIG:=mt7988a_bananapi_bpi-r4-emmc + UBOOT_IMAGE:=u-boot.fip + BL2_BOOTDEV:=emmc + BL2_SOC:=mt7988 + BL2_DDRTYPE:=comb + DEPENDS:=+trusted-firmware-a-mt7988-emmc-comb +endef + +define U-Boot/mt7988_bananapi_bpi-r4-sdmmc + NAME:=BananaPi BPi-R4 + BUILD_SUBTARGET:=filogic + BUILD_DEVICES:=bananapi_bpi-r4 + UBOOT_CONFIG:=mt7988a_bananapi_bpi-r4-sdmmc + UBOOT_IMAGE:=u-boot.fip + BL2_BOOTDEV:=sdmmc + BL2_SOC:=mt7988 + BL2_DDRTYPE:=comb + DEPENDS:=+trusted-firmware-a-mt7988-sdmmc-comb +endef + +define U-Boot/mt7988_bananapi_bpi-r4-snand + NAME:=BananaPi BPi-R4 + BUILD_SUBTARGET:=filogic + BUILD_DEVICES:=bananapi_bpi-r4 + UBOOT_CONFIG:=mt7988a_bananapi_bpi-r4-snand + UBOOT_IMAGE:=u-boot.fip + BL2_BOOTDEV:=spim-nand-ubi + BL2_SOC:=mt7988 + BL2_DDRTYPE:=comb + DEPENDS:=+trusted-firmware-a-mt7988-spim-nand-ubi-comb +endef + define U-Boot/mt7988_rfb-spim-nand NAME:=MT7988 Reference Board BUILD_SUBTARGET:=filogic @@ -581,6 +626,7 @@ UBOOT_TARGETS := \ mt7620_rfb \ mt7621_nand_rfb \ mt7621_rfb \ + mt7621_zbtlink_zbt-wg3526-16m \ mt7622_bananapi_bpi-r64-emmc \ mt7622_bananapi_bpi-r64-sdmmc \ mt7622_bananapi_bpi-r64-snand \ @@ -592,7 +638,7 @@ UBOOT_TARGETS := \ mt7623n_bpir2 \ mt7623a_unielec_u7623 \ mt7628_rfb \ - ravpower_rp-wd009 \ + mt7628_ravpower_rp-wd009 \ mt7629_rfb \ mt7981_cmcc_rax3000m-emmc \ mt7981_cmcc_rax3000m-nand \ @@ -610,6 +656,8 @@ UBOOT_TARGETS := \ mt7986_bananapi_bpi-r3-sdmmc \ mt7986_bananapi_bpi-r3-snand \ mt7986_bananapi_bpi-r3-nor \ + mt7986_bananapi_bpi-r3-mini-emmc \ + mt7986_bananapi_bpi-r3-mini-snand \ mt7986_glinet_gl-mt6000 \ mt7986_bananapi_bpi-r3-mini-emmc \ mt7986_bananapi_bpi-r3-mini-snand \ @@ -620,6 +668,9 @@ UBOOT_TARGETS := \ mt7986_xiaomi_redmi-router-ax6000 \ mt7986_zyxel_ex5601-t0 \ mt7986_rfb \ + mt7988_bananapi_bpi-r4-emmc \ + mt7988_bananapi_bpi-r4-sdmmc \ + mt7988_bananapi_bpi-r4-snand \ mt7988_rfb-spim-nand \ mt7988_rfb-snand \ mt7988_rfb-nor \ diff --git a/package/boot/uboot-mediatek/patches/000-mtk-20-configs-mt7622-enable-environment-for-mt7622_rfb.patch b/package/boot/uboot-mediatek/patches/000-mtk-20-configs-mt7622-enable-environment-for-mt7622_rfb.patch index 60eda91124b18e..dcbf8b953fa8d1 100644 --- a/package/boot/uboot-mediatek/patches/000-mtk-20-configs-mt7622-enable-environment-for-mt7622_rfb.patch +++ b/package/boot/uboot-mediatek/patches/000-mtk-20-configs-mt7622-enable-environment-for-mt7622_rfb.patch @@ -18,9 +18,9 @@ Signed-off-by: Weijie Gao CONFIG_DEFAULT_DEVICE_TREE="mt7622-rfb" +CONFIG_ENV_SIZE=0x20000 +CONFIG_ENV_OFFSET=0x280000 - CONFIG_SYS_PROMPT="MT7622> " CONFIG_DEBUG_UART_BASE=0x11002000 CONFIG_DEBUG_UART_CLOCK=25000000 + CONFIG_SYS_LOAD_ADDR=0x4007ff28 @@ -25,6 +27,9 @@ CONFIG_CMD_SF_TEST=y CONFIG_CMD_PING=y CONFIG_CMD_SMC=y diff --git a/package/boot/uboot-mediatek/patches/100-00-clk-remove-log_ret-from-clk_get_rate.patch b/package/boot/uboot-mediatek/patches/100-00-clk-remove-log_ret-from-clk_get_rate.patch deleted file mode 100644 index d5f6f7376224f1..00000000000000 --- a/package/boot/uboot-mediatek/patches/100-00-clk-remove-log_ret-from-clk_get_rate.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 19f2aa053d5531a9ca0ece04dca172a522d58b90 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Fri, 29 Jul 2022 11:32:28 +0800 -Subject: [PATCH 32/71] clk: remove log_ret from clk_get_rate - -The return value of clk_get_rate is ulong, an unsigned type. The size of -ulong depends on the cpu architecture, i.e. 4 bytes on 32-bit CPUs and -8 bytes on 64-bit CPUs. - -However log_ret only accepts and returns value in int type, a fixed 4-byte -type. This may truncate the real clock value and cause unexpected error on -64-bit platforms. - -This patch removes log_ret to solve this issue. - -Signed-off-by: Weijie Gao ---- - drivers/clk/clk-uclass.c | 7 +------ - 1 file changed, 1 insertion(+), 6 deletions(-) - ---- a/drivers/clk/clk-uclass.c -+++ b/drivers/clk/clk-uclass.c -@@ -471,7 +471,6 @@ void clk_free(struct clk *clk) - ulong clk_get_rate(struct clk *clk) - { - const struct clk_ops *ops; -- int ret; - - debug("%s(clk=%p)\n", __func__, clk); - if (!clk_valid(clk)) -@@ -481,11 +480,7 @@ ulong clk_get_rate(struct clk *clk) - if (!ops->get_rate) - return -ENOSYS; - -- ret = ops->get_rate(clk); -- if (ret) -- return log_ret(ret); -- -- return 0; -+ return ops->get_rate(clk); - } - - struct clk *clk_get_parent(struct clk *clk) diff --git a/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch b/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch index da87978aef31bb..9b02b4dc6305e8 100644 --- a/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch +++ b/package/boot/uboot-mediatek/patches/100-04-env-add-support-for-generic-MTD-device.patch @@ -17,37 +17,18 @@ Signed-off-by: Weijie Gao 7 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 env/mtd.c ---- a/cmd/nvedit.c -+++ b/cmd/nvedit.c -@@ -48,6 +48,7 @@ DECLARE_GLOBAL_DATA_PTR; - defined(CONFIG_ENV_IS_IN_MMC) || \ - defined(CONFIG_ENV_IS_IN_FAT) || \ - defined(CONFIG_ENV_IS_IN_EXT4) || \ -+ defined(CONFIG_ENV_IS_IN_MTD) || \ - defined(CONFIG_ENV_IS_IN_NAND) || \ - defined(CONFIG_ENV_IS_IN_NVRAM) || \ - defined(CONFIG_ENV_IS_IN_ONENAND) || \ -@@ -61,7 +62,7 @@ DECLARE_GLOBAL_DATA_PTR; - - #if !defined(ENV_IS_IN_DEVICE) && \ - !defined(CONFIG_ENV_IS_NOWHERE) --# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\ -+# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|MTD|\ - NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE - #endif - --- a/env/Kconfig +++ b/env/Kconfig -@@ -62,7 +62,7 @@ config ENV_IS_NOWHERE +@@ -61,7 +61,7 @@ config ENV_IS_DEFAULT !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \ !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \ !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \ - !ENV_IS_IN_UBI + !ENV_IS_IN_UBI && !ENV_IS_IN_MTD - help - Define this if you don't want to or can't have an environment stored - on a storage medium. In this case the environment will still exist -@@ -251,6 +251,27 @@ config ENV_IS_IN_MMC + select ENV_IS_NOWHERE + + config ENV_IS_NOWHERE +@@ -254,6 +254,27 @@ config ENV_IS_IN_MMC offset: "u-boot,mmc-env-offset", "u-boot,mmc-env-offset-redundant". CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND are not used. @@ -75,7 +56,7 @@ Signed-off-by: Weijie Gao config ENV_IS_IN_NAND bool "Environment in a NAND device" depends on !CHAIN_OF_TRUST -@@ -558,10 +579,16 @@ config ENV_ADDR_REDUND +@@ -561,10 +582,16 @@ config ENV_ADDR_REDUND Offset from the start of the device (or partition) of the redundant environment location. @@ -93,7 +74,7 @@ Signed-off-by: Weijie Gao default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC default 0x140000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH default 0xF0000 if ARCH_SUNXI -@@ -609,6 +636,12 @@ config ENV_SECT_SIZE +@@ -622,6 +649,12 @@ config ENV_SECT_SIZE help Size of the sector containing the environment. @@ -118,7 +99,7 @@ Signed-off-by: Weijie Gao obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_FLASH) += flash.o --- a/env/env.c +++ b/env/env.c -@@ -69,6 +69,9 @@ static enum env_location env_locations[] +@@ -46,6 +46,9 @@ static enum env_location env_locations[] #ifdef CONFIG_ENV_IS_IN_MMC ENVL_MMC, #endif diff --git a/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch b/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch index 93fc32cf9ec502..da4dce917ba87e 100644 --- a/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch +++ b/package/boot/uboot-mediatek/patches/100-08-common-board_r-add-support-to-initialize-NMBM-after-.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/common/board_r.c +++ b/common/board_r.c -@@ -388,6 +388,20 @@ static int initr_nand(void) +@@ -373,6 +373,20 @@ static int initr_nand(void) } #endif @@ -34,7 +34,7 @@ Signed-off-by: Weijie Gao #if defined(CONFIG_CMD_ONENAND) /* go init the NAND */ static int initr_onenand(void) -@@ -696,6 +710,9 @@ static init_fnc_t init_sequence_r[] = { +@@ -675,6 +689,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_CMD_ONENAND initr_onenand, #endif diff --git a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch index 35d8f115f60e0c..4eb2bc9ccfe063 100644 --- a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch +++ b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -1353,6 +1353,12 @@ config CMD_NAND_TORTURE +@@ -1392,6 +1392,12 @@ config CMD_NAND_TORTURE endif # CMD_NAND @@ -30,7 +30,7 @@ Signed-off-by: Weijie Gao depends on NVME --- a/cmd/Makefile +++ b/cmd/Makefile -@@ -125,6 +125,7 @@ obj-y += legacy-mtd-utils.o +@@ -127,6 +127,7 @@ obj-y += legacy-mtd-utils.o endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o diff --git a/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch b/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch index 6336fb33f57f8e..c6358f328775ed 100644 --- a/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch +++ b/package/boot/uboot-mediatek/patches/100-10-cmd-mtd-add-markbad-subcommand-for-NMBM-testing.patch @@ -63,7 +63,7 @@ Signed-off-by: SkyLake.Huang #ifdef CONFIG_AUTO_COMPLETE static int mtd_name_complete(int argc, char *const argv[], char last_char, int maxv, char *cmdv[]) -@@ -552,6 +588,7 @@ static char mtd_help_text[] = +@@ -551,6 +587,7 @@ U_BOOT_LONGHELP(mtd, "\n" "Specific functions:\n" "mtd bad \n" @@ -71,7 +71,7 @@ Signed-off-by: SkyLake.Huang "\n" "With:\n" "\t: NAND partition/chip name (or corresponding DM device name or OF path)\n" -@@ -577,4 +614,6 @@ U_BOOT_CMD_WITH_SUBCMDS(mtd, "MTD utils" +@@ -575,4 +612,6 @@ U_BOOT_CMD_WITH_SUBCMDS(mtd, "MTD utils" U_BOOT_SUBCMD_MKENT_COMPLETE(erase, 4, 0, do_mtd_erase, mtd_name_complete), U_BOOT_SUBCMD_MKENT_COMPLETE(bad, 2, 1, do_mtd_bad, diff --git a/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch b/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch index 0b4ee32b625261..dbb1e2e59d2510 100644 --- a/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch +++ b/package/boot/uboot-mediatek/patches/100-11-env-add-support-for-NMBM-upper-MTD-layer.patch @@ -17,37 +17,17 @@ Signed-off-by: Weijie Gao 7 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 env/nmbm.c ---- a/cmd/nvedit.c -+++ b/cmd/nvedit.c -@@ -50,6 +50,7 @@ DECLARE_GLOBAL_DATA_PTR; - defined(CONFIG_ENV_IS_IN_EXT4) || \ - defined(CONFIG_ENV_IS_IN_MTD) || \ - defined(CONFIG_ENV_IS_IN_NAND) || \ -+ defined(CONFIG_ENV_IS_IN_NMBM) || \ - defined(CONFIG_ENV_IS_IN_NVRAM) || \ - defined(CONFIG_ENV_IS_IN_ONENAND) || \ - defined(CONFIG_ENV_IS_IN_SPI_FLASH) || \ -@@ -63,7 +64,7 @@ DECLARE_GLOBAL_DATA_PTR; - #if !defined(ENV_IS_IN_DEVICE) && \ - !defined(CONFIG_ENV_IS_NOWHERE) - # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|MTD|\ --NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE -+NAND|NMBM|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE - #endif - - /* --- a/env/Kconfig +++ b/env/Kconfig -@@ -62,7 +62,7 @@ config ENV_IS_NOWHERE +@@ -59,6 +59,7 @@ config ENV_IS_DEFAULT + def_bool y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \ + !ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \ !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \ ++ !ENV_IS_IN_NMBM && \ !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \ !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \ -- !ENV_IS_IN_UBI && !ENV_IS_IN_MTD -+ !ENV_IS_IN_UBI && !ENV_IS_IN_NMBM && !ENV_IS_IN_MTD - help - Define this if you don't want to or can't have an environment stored - on a storage medium. In this case the environment will still exist -@@ -312,6 +312,21 @@ config ENV_RANGE + !ENV_IS_IN_UBI && !ENV_IS_IN_MTD +@@ -315,6 +316,21 @@ config ENV_RANGE Specifying a range with more erase blocks than are needed to hold CONFIG_ENV_SIZE allows bad blocks within the range to be avoided. @@ -69,7 +49,7 @@ Signed-off-by: Weijie Gao config ENV_IS_IN_NVRAM bool "Environment in a non-volatile RAM" depends on !CHAIN_OF_TRUST -@@ -588,7 +603,7 @@ config ENV_MTD_NAME +@@ -591,7 +607,7 @@ config ENV_MTD_NAME config ENV_OFFSET hex "Environment offset" depends on ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \ @@ -90,7 +70,7 @@ Signed-off-by: Weijie Gao --- a/env/env.c +++ b/env/env.c -@@ -75,6 +75,9 @@ static enum env_location env_locations[] +@@ -52,6 +52,9 @@ static enum env_location env_locations[] #ifdef CONFIG_ENV_IS_IN_NAND ENVL_NAND, #endif diff --git a/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch b/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch index f3831e07f7dfbe..e6e12ae24cdcbc 100644 --- a/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch +++ b/package/boot/uboot-mediatek/patches/100-13-cmd-add-a-new-command-for-NAND-flash-debugging.patch @@ -26,7 +26,7 @@ Signed-off-by: Weijie Gao --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -1353,6 +1353,14 @@ config CMD_NAND_TORTURE +@@ -1392,6 +1392,14 @@ config CMD_NAND_TORTURE endif # CMD_NAND @@ -43,7 +43,7 @@ Signed-off-by: Weijie Gao bool "nmbm" --- a/cmd/Makefile +++ b/cmd/Makefile -@@ -125,6 +125,7 @@ obj-y += legacy-mtd-utils.o +@@ -127,6 +127,7 @@ obj-y += legacy-mtd-utils.o endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o diff --git a/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch b/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch index d9a645d20efec9..da09cd9c088322 100644 --- a/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch +++ b/package/boot/uboot-mediatek/patches/100-14-mtd-spi-nor-add-support-to-read-flash-unique-ID.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c -@@ -2848,6 +2848,100 @@ static int spi_nor_init_params(struct sp +@@ -2854,6 +2854,100 @@ static int spi_nor_init_params(struct sp return 0; } @@ -114,7 +114,7 @@ Signed-off-by: Weijie Gao static int spi_nor_hwcaps2cmd(u32 hwcaps, const int table[][2], size_t size) { size_t i; -@@ -4045,6 +4139,7 @@ int spi_nor_scan(struct spi_nor *nor) +@@ -4051,6 +4145,7 @@ int spi_nor_scan(struct spi_nor *nor) nor->write = spi_nor_write_data; nor->read_reg = spi_nor_read_reg; nor->write_reg = spi_nor_write_reg; diff --git a/package/boot/uboot-mediatek/patches/100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch b/package/boot/uboot-mediatek/patches/100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch index ce59cc73aef051..f7cbd8d052c3aa 100644 --- a/package/boot/uboot-mediatek/patches/100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch +++ b/package/boot/uboot-mediatek/patches/100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch @@ -12,7 +12,7 @@ Signed-off-by: Weijie Gao --- a/cmd/sf.c +++ b/cmd/sf.c -@@ -407,6 +407,14 @@ static int do_spi_protect(int argc, char +@@ -412,6 +412,14 @@ static int do_spi_protect(int argc, char return ret == 0 ? 0 : 1; } @@ -27,22 +27,20 @@ Signed-off-by: Weijie Gao enum { STAGE_ERASE, STAGE_CHECK, -@@ -601,6 +609,8 @@ static int do_spi_flash(struct cmd_tbl * +@@ -606,6 +614,8 @@ static int do_spi_flash(struct cmd_tbl * ret = do_spi_flash_erase(argc, argv); - else if (strcmp(cmd, "protect") == 0) + else if (IS_ENABLED(CONFIG_SPI_FLASH_LOCK) && strcmp(cmd, "protect") == 0) ret = do_spi_protect(argc, argv); + else if (strcmp(cmd, "uuid") == 0) + ret = do_spi_flash_read_uuid(); else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test")) ret = do_spi_flash_test(argc, argv); else -@@ -626,7 +636,8 @@ static const char long_help[] = - " at `addr' to flash at `offset'\n" - " or to start of mtd `partition'\n" - "sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting\n" -- " at address 'sector'" -+ " at address 'sector'\n" -+ "sf uuid - read uuid from flash" +@@ -636,6 +646,7 @@ U_BOOT_LONGHELP(sf, #ifdef CONFIG_CMD_SF_TEST "\nsf test offset len - run a very basic destructive test" #endif ++ "sf uuid - read uuid from flash" + ); + + U_BOOT_CMD( diff --git a/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch b/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch index 315f7f92a3d794..0438895fdbaaab 100644 --- a/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch +++ b/package/boot/uboot-mediatek/patches/100-16-cmd-bootmenu-add-ability-to-select-item-by-shortkey.patch @@ -255,15 +255,15 @@ Signed-off-by: Weijie Gao }; /** enum bootmenu_key - keys that can be returned by the bootmenu */ -@@ -54,6 +59,7 @@ enum bootmenu_key { - BKEY_MINUS, - BKEY_SPACE, +@@ -51,6 +56,7 @@ enum bootmenu_key { + BKEY_SELECT, + BKEY_QUIT, BKEY_SAVE, + BKEY_CHOICE, - BKEY_COUNT, - }; -@@ -76,7 +82,7 @@ enum bootmenu_key { + /* 'extra' keys, which are used by menus but not cedit */ + BKEY_PLUS, +@@ -81,7 +87,7 @@ enum bootmenu_key { * anything else: KEY_NONE */ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, @@ -272,7 +272,7 @@ Signed-off-by: Weijie Gao /** * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled -@@ -102,7 +108,7 @@ enum bootmenu_key bootmenu_autoboot_loop +@@ -107,7 +113,7 @@ enum bootmenu_key bootmenu_autoboot_loop * Space: BKEY_SPACE */ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, @@ -281,7 +281,7 @@ Signed-off-by: Weijie Gao /** * bootmenu_conv_key() - Convert a U-Boot keypress into a menu key -@@ -110,6 +116,7 @@ enum bootmenu_key bootmenu_loop(struct b +@@ -115,6 +121,7 @@ enum bootmenu_key bootmenu_loop(struct b * @ichar: Keypress to convert (ASCII, including control characters) * Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none */ @@ -301,7 +301,7 @@ Signed-off-by: Weijie Gao switch (key) { case BKEY_UP: -@@ -1937,7 +1937,7 @@ char *eficonfig_choice_change_boot_order +@@ -1838,7 +1838,7 @@ char *eficonfig_choice_change_boot_order cli_ch_init(cch); while (1) { @@ -312,7 +312,7 @@ Signed-off-by: Weijie Gao case BKEY_PLUS: --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c -@@ -231,7 +231,7 @@ int bootflow_menu_run(struct bootstd_pri +@@ -235,7 +235,7 @@ int bootflow_menu_run(struct bootstd_pri key = 0; if (ichar) { diff --git a/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch b/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch index 149a156ba26bae..f017ce92ade363 100644 --- a/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch +++ b/package/boot/uboot-mediatek/patches/100-17-common-spl-spl_nand-enable-CONFIG_SYS_NAND_U_BOOT_OF.patch @@ -14,7 +14,7 @@ Signed-off-by: Weijie Gao --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c -@@ -16,7 +16,11 @@ +@@ -17,7 +17,11 @@ uint32_t __weak spl_nand_get_uboot_raw_page(void) { diff --git a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch index 93a940b943f7c8..ef20c2dfb6c6cb 100644 --- a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch +++ b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch @@ -89,14 +89,14 @@ Signed-off-by: Weijie Gao reg = <0x11014000 0x1000>; --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig -@@ -133,9 +133,11 @@ config SYS_CONFIG_NAME +@@ -144,9 +144,11 @@ config SYS_CONFIG_NAME config MTK_BROM_HEADER_INFO string - default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7629 || TARGET_MT7622 + default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7622 default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8183 - default "media=snand;nandinfo=2k+64" if TARGET_MT7981 || TARGET_MT7986 + default "media=snand;nandinfo=2k+64" if TARGET_MT7981 || TARGET_MT7986 || TARGET_MT7988 default "lk=1" if TARGET_MT7623 +source "board/mediatek/mt7629/Kconfig" diff --git a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch index cb3f1ff2af5182..9dc1a577228bcf 100644 --- a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch +++ b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch @@ -18,7 +18,7 @@ Signed-off-by: Weijie Gao --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1308,6 +1308,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1425,6 +1425,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7623n-bananapi-bpi-r2.dtb \ mt7629-rfb.dtb \ mt7981-rfb.dtb \ diff --git a/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch b/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch index bd68677eb063f0..15e943b1c020ad 100644 --- a/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch +++ b/package/boot/uboot-mediatek/patches/100-21-mtd-spi-nor-add-more-flash-ids.patch @@ -13,7 +13,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c -@@ -673,6 +673,7 @@ static int set_4byte(struct spi_nor *nor +@@ -674,6 +674,7 @@ static int set_4byte(struct spi_nor *nor case SNOR_MFR_ISSI: case SNOR_MFR_MACRONIX: case SNOR_MFR_WINBOND: @@ -45,7 +45,7 @@ Signed-off-by: Weijie Gao INFO("gd25lq128", 0xc86018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) -@@ -468,6 +474,16 @@ const struct flash_info spi_nor_ids[] = +@@ -474,6 +480,16 @@ const struct flash_info spi_nor_ids[] = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, { @@ -62,7 +62,7 @@ Signed-off-by: Weijie Gao INFO("w25q128jw", 0xef8018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) -@@ -517,6 +533,11 @@ const struct flash_info spi_nor_ids[] = +@@ -523,6 +539,11 @@ const struct flash_info spi_nor_ids[] = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, { INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, diff --git a/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch b/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch index 0e233bb1d2903e..20489d87266744 100644 --- a/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch +++ b/package/boot/uboot-mediatek/patches/100-22-mtd-spi-nand-backport-from-upstream-kernel.patch @@ -20,66 +20,17 @@ Signed-off-by: Weijie Gao 10 files changed, 923 insertions(+), 225 deletions(-) create mode 100644 drivers/mtd/nand/spi/etron.c ---- a/drivers/mtd/nand/spi/Kconfig -+++ b/drivers/mtd/nand/spi/Kconfig -@@ -5,3 +5,4 @@ menuconfig MTD_SPI_NAND - select SPI_MEM - help - This is the framework for the SPI NAND device drivers. -+ --- a/drivers/mtd/nand/spi/Makefile +++ b/drivers/mtd/nand/spi/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 --spinand-objs := core.o gigadevice.o macronix.o micron.o toshiba.o winbond.o -+spinand-objs := core.o gigadevice.o macronix.o micron.o toshiba.o winbond.o etron.o +-spinand-objs := core.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o ++spinand-objs := core.o etron.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.o --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - #include - #include - #else -@@ -451,10 +452,11 @@ out: - return status & STATUS_BUSY ? -ETIMEDOUT : 0; - } - --static int spinand_read_id_op(struct spinand_device *spinand, u8 *buf) -+static int spinand_read_id_op(struct spinand_device *spinand, u8 naddr, -+ u8 ndummy, u8 *buf) - { -- struct spi_mem_op op = SPINAND_READID_OP(0, spinand->scratchbuf, -- SPINAND_MAX_ID_LEN); -+ struct spi_mem_op op = SPINAND_READID_OP( -+ naddr, ndummy, spinand->scratchbuf, SPINAND_MAX_ID_LEN); - int ret; - - ret = spi_mem_exec_op(spinand->slave, &op); -@@ -464,18 +466,6 @@ static int spinand_read_id_op(struct spi - return ret; - } - --static int spinand_reset_op(struct spinand_device *spinand) --{ -- struct spi_mem_op op = SPINAND_RESET_OP; -- int ret; -- -- ret = spi_mem_exec_op(spinand->slave, &op); -- if (ret) -- return ret; -- -- return spinand_wait(spinand, NULL); --} -- - static int spinand_lock_block(struct spinand_device *spinand, u8 lock) - { - return spinand_write_reg_op(spinand, REG_BLOCK_LOCK, lock); -@@ -829,6 +819,7 @@ static const struct nand_ops spinand_ops +@@ -822,6 +822,7 @@ static const struct nand_ops spinand_ops }; static const struct spinand_manufacturer *spinand_manufacturers[] = { @@ -87,140 +38,6 @@ Signed-off-by: Weijie Gao &gigadevice_spinand_manufacturer, ¯onix_spinand_manufacturer, µn_spinand_manufacturer, -@@ -836,24 +827,63 @@ static const struct spinand_manufacturer - &winbond_spinand_manufacturer, - }; - --static int spinand_manufacturer_detect(struct spinand_device *spinand) -+static int spinand_manufacturer_match(struct spinand_device *spinand, -+ enum spinand_readid_method rdid_method) - { -+ u8 *id = spinand->id.data; - unsigned int i; - int ret; - - for (i = 0; i < ARRAY_SIZE(spinand_manufacturers); i++) { -- ret = spinand_manufacturers[i]->ops->detect(spinand); -- if (ret > 0) { -- spinand->manufacturer = spinand_manufacturers[i]; -- return 0; -- } else if (ret < 0) { -- return ret; -- } -+ const struct spinand_manufacturer *manufacturer = -+ spinand_manufacturers[i]; -+ -+ if (id[0] != manufacturer->id) -+ continue; -+ -+ ret = spinand_match_and_init(spinand, -+ manufacturer->chips, -+ manufacturer->nchips, -+ rdid_method); -+ if (ret < 0) -+ continue; -+ -+ spinand->manufacturer = manufacturer; -+ return 0; - } - - return -ENOTSUPP; - } - -+static int spinand_id_detect(struct spinand_device *spinand) -+{ -+ u8 *id = spinand->id.data; -+ int ret; -+ -+ ret = spinand_read_id_op(spinand, 0, 0, id); -+ if (ret) -+ return ret; -+ ret = spinand_manufacturer_match(spinand, SPINAND_READID_METHOD_OPCODE); -+ if (!ret) -+ return 0; -+ -+ ret = spinand_read_id_op(spinand, 1, 0, id); -+ if (ret) -+ return ret; -+ ret = spinand_manufacturer_match(spinand, -+ SPINAND_READID_METHOD_OPCODE_ADDR); -+ if (!ret) -+ return 0; -+ -+ ret = spinand_read_id_op(spinand, 0, 1, id); -+ if (ret) -+ return ret; -+ ret = spinand_manufacturer_match(spinand, -+ SPINAND_READID_METHOD_OPCODE_DUMMY); -+ -+ return ret; -+} -+ - static int spinand_manufacturer_init(struct spinand_device *spinand) - { - if (spinand->manufacturer->ops->init) -@@ -909,9 +939,9 @@ spinand_select_op_variant(struct spinand - * @spinand: SPI NAND object - * @table: SPI NAND device description table - * @table_size: size of the device description table -+ * @rdid_method: read id method to match - * -- * Should be used by SPI NAND manufacturer drivers when they want to find a -- * match between a device ID retrieved through the READ_ID command and an -+ * Match between a device ID retrieved through the READ_ID command and an - * entry in the SPI NAND description table. If a match is found, the spinand - * object will be initialized with information provided by the matching - * spinand_info entry. -@@ -920,8 +950,10 @@ spinand_select_op_variant(struct spinand - */ - int spinand_match_and_init(struct spinand_device *spinand, - const struct spinand_info *table, -- unsigned int table_size, u8 devid) -+ unsigned int table_size, -+ enum spinand_readid_method rdid_method) - { -+ u8 *id = spinand->id.data; - struct nand_device *nand = spinand_to_nand(spinand); - unsigned int i; - -@@ -929,13 +961,17 @@ int spinand_match_and_init(struct spinan - const struct spinand_info *info = &table[i]; - const struct spi_mem_op *op; - -- if (devid != info->devid) -+ if (rdid_method != info->devid.method) -+ continue; -+ -+ if (memcmp(id + 1, info->devid.id, info->devid.len)) - continue; - - nand->memorg = table[i].memorg; - nand->eccreq = table[i].eccreq; - spinand->eccinfo = table[i].eccinfo; - spinand->flags = table[i].flags; -+ spinand->id.len = 1 + table[i].devid.len; - spinand->select_target = table[i].select_target; - - op = spinand_select_op_variant(spinand, -@@ -967,17 +1003,7 @@ static int spinand_detect(struct spinand - struct nand_device *nand = spinand_to_nand(spinand); - int ret; - -- ret = spinand_reset_op(spinand); -- if (ret) -- return ret; -- -- ret = spinand_read_id_op(spinand, spinand->id.data); -- if (ret) -- return ret; -- -- spinand->id.len = SPINAND_MAX_ID_LEN; -- -- ret = spinand_manufacturer_detect(spinand); -+ ret = spinand_id_detect(spinand); - if (ret) { - dev_err(spinand->slave->dev, "unknown raw ID %02x %02x %02x %02x\n", - spinand->id.data[0], spinand->id.data[1], --- /dev/null +++ b/drivers/mtd/nand/spi/etron.c @@ -0,0 +1,181 @@ @@ -320,7 +137,7 @@ Signed-off-by: Weijie Gao + /* EM73C 1Gb 3.3V */ + SPINAND_INFO("EM73C044VCF", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x25), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -330,7 +147,7 @@ Signed-off-by: Weijie Gao + /* EM7xD 2Gb */ + SPINAND_INFO("EM73D044VCR", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x41), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -339,7 +156,7 @@ Signed-off-by: Weijie Gao + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)), + SPINAND_INFO("EM73D044VCO", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x3A), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -348,7 +165,7 @@ Signed-off-by: Weijie Gao + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)), + SPINAND_INFO("EM78D044VCM", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x8E), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -358,7 +175,7 @@ Signed-off-by: Weijie Gao + /* EM7xE 4Gb */ + SPINAND_INFO("EM73E044VCE", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x3B), -+ NAND_MEMORG(1, 2048, 128, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -367,7 +184,7 @@ Signed-off-by: Weijie Gao + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)), + SPINAND_INFO("EM78E044VCD", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x8F), -+ NAND_MEMORG(1, 2048, 128, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -377,7 +194,7 @@ Signed-off-by: Weijie Gao + /* EM7xF044VCA 8Gb */ + SPINAND_INFO("EM73F044VCA", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15), -+ NAND_MEMORG(1, 4096, 256, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 4096, 256, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -386,7 +203,7 @@ Signed-off-by: Weijie Gao + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)), + SPINAND_INFO("EM78F044VCA", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x8D), -+ NAND_MEMORG(1, 4096, 256, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 4096, 256, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -407,45 +224,19 @@ Signed-off-by: Weijie Gao +}; --- a/drivers/mtd/nand/spi/gigadevice.c +++ b/drivers/mtd/nand/spi/gigadevice.c -@@ -22,8 +22,13 @@ - - #define GD5FXGQXXEXXG_REG_STATUS2 0xf0 - -+#define GD5FXGQ4UXFXXG_STATUS_ECC_MASK (7 << 4) -+#define GD5FXGQ4UXFXXG_STATUS_ECC_NO_BITFLIPS (0 << 4) -+#define GD5FXGQ4UXFXXG_STATUS_ECC_1_3_BITFLIPS (1 << 4) -+#define GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR (7 << 4) -+ - /* Q4 devices, QUADIO: Dummy bytes valid for 1 and 2 GBit variants */ --static SPINAND_OP_VARIANTS(gd5fxgq4_read_cache_variants, -+static SPINAND_OP_VARIANTS(read_cache_variants, - SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), -@@ -31,8 +36,17 @@ static SPINAND_OP_VARIANTS(gd5fxgq4_read - SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); +@@ -43,6 +43,24 @@ static SPINAND_OP_VARIANTS(read_cache_va + SPINAND_PAGE_READ_FROM_CACHE_OP_3A(true, 0, 1, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_OP_3A(false, 0, 0, NULL, 0)); --/* Q5 devices, QUADIO: Dummy bytes only valid for 1 GBit variants */ --static SPINAND_OP_VARIANTS(gd5f1gq5_read_cache_variants, -+static SPINAND_OP_VARIANTS(read_cache_variants_f, -+ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0), -+ SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(0, 1, NULL, 0), -+ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), -+ SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(0, 1, NULL, 0), -+ SPINAND_PAGE_READ_FROM_CACHE_OP_3A(true, 0, 1, NULL, 0), -+ SPINAND_PAGE_READ_FROM_CACHE_OP_3A(false, 0, 0, NULL, 0)); -+ -+/* For Q5 devices, QUADIO use different dummy byte settings */ +/* Q5 1Gb */ +static SPINAND_OP_VARIANTS(dummy2_read_cache_variants, - SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), -@@ -40,6 +54,15 @@ static SPINAND_OP_VARIANTS(gd5f1gq5_read - SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), - SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); - ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ +/* Q5 2Gb & 4Gb */ +static SPINAND_OP_VARIANTS(dummy4_read_cache_variants, + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0), @@ -458,124 +249,10 @@ Signed-off-by: Weijie Gao static SPINAND_OP_VARIANTS(write_cache_variants, SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), SPINAND_PROG_LOAD(true, 0, NULL, 0)); -@@ -48,7 +71,65 @@ static SPINAND_OP_VARIANTS(update_cache_ - SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), - SPINAND_PROG_LOAD(false, 0, NULL, 0)); - --static int gd5fxgqxxexxg_ooblayout_ecc(struct mtd_info *mtd, int section, -+static int gd5fxgq4xa_ooblayout_ecc(struct mtd_info *mtd, int section, -+ struct mtd_oob_region *region) -+{ -+ if (section > 3) -+ return -ERANGE; -+ -+ region->offset = (16 * section) + 8; -+ region->length = 8; -+ -+ return 0; -+} -+ -+static int gd5fxgq4xa_ooblayout_free(struct mtd_info *mtd, int section, -+ struct mtd_oob_region *region) -+{ -+ if (section > 3) -+ return -ERANGE; -+ -+ if (section) { -+ region->offset = 16 * section; -+ region->length = 8; -+ } else { -+ /* section 0 has one byte reserved for bad block mark */ -+ region->offset = 1; -+ region->length = 7; -+ } -+ return 0; -+} -+ -+static const struct mtd_ooblayout_ops gd5fxgq4xa_ooblayout = { -+ .ecc = gd5fxgq4xa_ooblayout_ecc, -+ .rfree = gd5fxgq4xa_ooblayout_free, -+}; -+ -+static int gd5fxgq4xa_ecc_get_status(struct spinand_device *spinand, -+ u8 status) -+{ -+ switch (status & STATUS_ECC_MASK) { -+ case STATUS_ECC_NO_BITFLIPS: -+ return 0; -+ -+ case GD5FXGQ4XA_STATUS_ECC_1_7_BITFLIPS: -+ /* 1-7 bits are flipped. return the maximum. */ -+ return 7; -+ -+ case GD5FXGQ4XA_STATUS_ECC_8_BITFLIPS: -+ return 8; -+ -+ case STATUS_ECC_UNCOR_ERROR: -+ return -EBADMSG; -+ -+ default: -+ break; -+ } -+ -+ return -EINVAL; -+} -+ -+static int gd5fxgqx_variant2_ooblayout_ecc(struct mtd_info *mtd, int section, - struct mtd_oob_region *region) - { - if (section) -@@ -60,7 +141,7 @@ static int gd5fxgqxxexxg_ooblayout_ecc(s - return 0; - } - --static int gd5fxgqxxexxg_ooblayout_free(struct mtd_info *mtd, int section, -+static int gd5fxgqx_variant2_ooblayout_free(struct mtd_info *mtd, int section, - struct mtd_oob_region *region) - { - if (section) -@@ -73,7 +154,13 @@ static int gd5fxgqxxexxg_ooblayout_free( - return 0; - } - --static int gd5fxgq4xexxg_ecc_get_status(struct spinand_device *spinand, -+/* Valid for Q4/Q5 and Q6 (untested) devices */ -+static const struct mtd_ooblayout_ops gd5fxgqx_variant2_ooblayout = { -+ .ecc = gd5fxgqx_variant2_ooblayout_ecc, -+ .rfree = gd5fxgqx_variant2_ooblayout_free, -+}; -+ -+static int gd5fxgq4uexxg_ecc_get_status(struct spinand_device *spinand, - u8 status) - { - u8 status2; -@@ -152,59 +239,214 @@ static int gd5fxgq5xexxg_ecc_get_status( +@@ -268,7 +286,45 @@ static int gd5fxgq4ufxxg_ecc_get_status( return -EINVAL; } --static const struct mtd_ooblayout_ops gd5fxgqxxexxg_ooblayout = { -- .ecc = gd5fxgqxxexxg_ooblayout_ecc, -- .rfree = gd5fxgqxxexxg_ooblayout_free, -+static int gd5fxgq4ufxxg_ecc_get_status(struct spinand_device *spinand, -+ u8 status) -+{ -+ switch (status & GD5FXGQ4UXFXXG_STATUS_ECC_MASK) { -+ case GD5FXGQ4UXFXXG_STATUS_ECC_NO_BITFLIPS: -+ return 0; -+ -+ case GD5FXGQ4UXFXXG_STATUS_ECC_1_3_BITFLIPS: -+ return 3; -+ -+ case GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR: -+ return -EBADMSG; -+ -+ default: /* (2 << 4) through (6 << 4) are 4-8 corrected errors */ -+ return ((status & GD5FXGQ4UXFXXG_STATUS_ECC_MASK) >> 4) + 2; -+ } -+ -+ return -EINVAL; -+} -+ +static int esmt_1_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) +{ @@ -603,90 +280,28 @@ Signed-off-by: Weijie Gao +static const struct mtd_ooblayout_ops esmt_1_ooblayout = { + .ecc = esmt_1_ooblayout_ecc, + .rfree = esmt_1_ooblayout_free, - }; - ++ }; ++ static const struct spinand_info gigadevice_spinand_table[] = { -- SPINAND_INFO("GD5F1GQ4UExxG", 0xd1, -- NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), + SPINAND_INFO("F50L1G41LB", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), -- SPINAND_INFO_OP_VARIANTS(&gd5fxgq4_read_cache_variants, -+ SPINAND_INFO_OP_VARIANTS(&dummy2_read_cache_variants, - &write_cache_variants, - &update_cache_variants), - 0, -- SPINAND_ECCINFO(&gd5fxgqxxexxg_ooblayout, -- gd5fxgq4xexxg_ecc_get_status)), -- SPINAND_INFO("GD5F1GQ5UExxG", 0x51, -+ SPINAND_ECCINFO(&esmt_1_ooblayout, NULL)), -+ SPINAND_INFO("GD5F1GQ4xA", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xf1), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, -+ gd5fxgq4xa_ecc_get_status)), -+ SPINAND_INFO("GD5F2GQ4xA", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xf2), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, -+ gd5fxgq4xa_ecc_get_status)), -+ SPINAND_INFO("GD5F4GQ4xA", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xf4), -+ NAND_MEMORG(1, 2048, 64, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, -+ gd5fxgq4xa_ecc_get_status)), -+ SPINAND_INFO("GD5F1GQ4UExxG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xd1), -+ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, -+ gd5fxgq4uexxg_ecc_get_status)), -+ SPINAND_INFO("GD5F1GQ4UFxxG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE, 0xb1, 0x48), -+ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants_f, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, -+ gd5fxgq4ufxxg_ecc_get_status)), -+ SPINAND_INFO("GD5F1GQ5UExxG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x51), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(4, 512), -- SPINAND_INFO_OP_VARIANTS(&gd5f1gq5_read_cache_variants, + SPINAND_INFO_OP_VARIANTS(&dummy2_read_cache_variants, - &write_cache_variants, - &update_cache_variants), -- 0, -- SPINAND_ECCINFO(&gd5fxgqxxexxg_ooblayout, -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, -+ gd5fxgq5xexxg_ecc_get_status)), ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&esmt_1_ooblayout, NULL)), + SPINAND_INFO("GD5F1GQ4xA", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xf1), + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), +@@ -349,6 +405,87 @@ static const struct spinand_info gigadev + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, + gd5fxgq5xexxg_ecc_get_status)), + SPINAND_INFO("GD5F2GQ5UExxG", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x52), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&dummy4_read_cache_variants, + &write_cache_variants, @@ -696,7 +311,7 @@ Signed-off-by: Weijie Gao + gd5fxgq5xexxg_ecc_get_status)), + SPINAND_INFO("GD5F4GQ6UExxG", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x55), -+ NAND_MEMORG(1, 2048, 128, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&dummy4_read_cache_variants, + &write_cache_variants, @@ -706,7 +321,7 @@ Signed-off-by: Weijie Gao + gd5fxgq5xexxg_ecc_get_status)), + SPINAND_INFO("GD5F1GM7UExxG", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x91), -+ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -716,7 +331,7 @@ Signed-off-by: Weijie Gao + gd5fxgq4uexxg_ecc_get_status)), + SPINAND_INFO("GD5F2GM7UExxG", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x92), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -726,7 +341,7 @@ Signed-off-by: Weijie Gao + gd5fxgq4uexxg_ecc_get_status)), + SPINAND_INFO("GD5F4GM8UExxG", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x95), -+ NAND_MEMORG(1, 2048, 128, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -736,7 +351,7 @@ Signed-off-by: Weijie Gao + gd5fxgq4uexxg_ecc_get_status)), + SPINAND_INFO("GD5F1GQ5UExxH", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x31), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&dummy2_read_cache_variants, + &write_cache_variants, @@ -746,7 +361,7 @@ Signed-off-by: Weijie Gao + gd5fxgq5xexxg_ecc_get_status)), + SPINAND_INFO("GD5F2GQ5UExxH", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x32), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&dummy4_read_cache_variants, + &write_cache_variants, @@ -756,600 +371,21 @@ Signed-off-by: Weijie Gao + gd5fxgq5xexxg_ecc_get_status)), + SPINAND_INFO("GD5F4GQ6UExxH", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), -+ NAND_MEMORG(1, 2048, 64, 64, 4096, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 4096, 40, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&dummy4_read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, - gd5fxgq5xexxg_ecc_get_status)), - }; - --static int gigadevice_spinand_detect(struct spinand_device *spinand) --{ -- u8 *id = spinand->id.data; -- int ret; -- -- /* -- * For GD NANDs, There is an address byte needed to shift in before IDs -- * are read out, so the first byte in raw_id is dummy. -- */ -- if (id[1] != SPINAND_MFR_GIGADEVICE) -- return 0; -- -- ret = spinand_match_and_init(spinand, gigadevice_spinand_table, -- ARRAY_SIZE(gigadevice_spinand_table), -- id[2]); -- if (ret) -- return ret; -- -- return 1; --} -- - static const struct spinand_manufacturer_ops gigadevice_spinand_manuf_ops = { -- .detect = gigadevice_spinand_detect, - }; - - const struct spinand_manufacturer gigadevice_spinand_manufacturer = { - .id = SPINAND_MFR_GIGADEVICE, - .name = "GigaDevice", -+ .chips = gigadevice_spinand_table, -+ .nchips = ARRAY_SIZE(gigadevice_spinand_table), - .ops = &gigadevice_spinand_manuf_ops, - }; ---- a/drivers/mtd/nand/spi/macronix.c -+++ b/drivers/mtd/nand/spi/macronix.c -@@ -105,7 +105,8 @@ static int mx35lf1ge4ab_ecc_get_status(s - } - - static const struct spinand_info macronix_spinand_table[] = { -- SPINAND_INFO("MX35LF1GE4AB", 0x12, -+ SPINAND_INFO("MX35LF1GE4AB", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x12), - NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), - NAND_ECCREQ(4, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -114,7 +115,8 @@ static const struct spinand_info macroni - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), -- SPINAND_INFO("MX35LF2GE4AB", 0x22, -+ SPINAND_INFO("MX35LF2GE4AB", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x22), - NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1), - NAND_ECCREQ(4, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -122,7 +124,96 @@ static const struct spinand_info macroni - &update_cache_variants), - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), -- SPINAND_INFO("MX35UF4GE4AD", 0xb7, -+ SPINAND_INFO("MX35LF2GE4AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x26), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35LF4GE4AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x37), -+ NAND_MEMORG(1, 4096, 128, 64, 2048, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35LF1G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14), -+ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), -+ SPINAND_INFO("MX35LF2G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), -+ SPINAND_INFO("MX35LF4G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), -+ NAND_MEMORG(1, 4096, 256, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), -+ SPINAND_INFO("MX31LF1GE4BC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX31UF1GE4BC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9e), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), ++ gd5fxgq5xexxg_ecc_get_status)), + -+ SPINAND_INFO("MX35LF2G14AC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x20), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(4, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF4G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb5), -+ NAND_MEMORG(1, 4096, 256, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF4GE4AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb7), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -131,7 +222,28 @@ static const struct spinand_info macroni - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), -- SPINAND_INFO("MX35UF2GE4AD", 0xa6, -+ SPINAND_INFO("MX35UF2G14AC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa0), -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(4, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF2G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa4), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF2GE4AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa6), - NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -140,16 +252,28 @@ static const struct spinand_info macroni - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), -- SPINAND_INFO("MX35UF2GE4AC", 0xa2, -+ SPINAND_INFO("MX35UF2GE4AC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa2), - NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), - NAND_ECCREQ(4, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF1G14AC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x90), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(4, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, - &write_cache_variants, - &update_cache_variants), - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), -- SPINAND_INFO("MX35UF1GE4AD", 0x96, -+ SPINAND_INFO("MX35UF1G24AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x94), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -158,7 +282,18 @@ static const struct spinand_info macroni - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, - mx35lf1ge4ab_ecc_get_status)), -- SPINAND_INFO("MX35UF1GE4AC", 0x92, -+ SPINAND_INFO("MX35UF1GE4AD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x96), -+ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ SPINAND_HAS_QE_BIT, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35UF1GE4AC", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x92), - NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), - NAND_ECCREQ(4, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -170,33 +305,13 @@ static const struct spinand_info macroni - - }; - --static int macronix_spinand_detect(struct spinand_device *spinand) --{ -- u8 *id = spinand->id.data; -- int ret; -- -- /* -- * Macronix SPI NAND read ID needs a dummy byte, so the first byte in -- * raw_id is garbage. -- */ -- if (id[1] != SPINAND_MFR_MACRONIX) -- return 0; -- -- ret = spinand_match_and_init(spinand, macronix_spinand_table, -- ARRAY_SIZE(macronix_spinand_table), -- id[2]); -- if (ret) -- return ret; -- -- return 1; --} -- - static const struct spinand_manufacturer_ops macronix_spinand_manuf_ops = { -- .detect = macronix_spinand_detect, - }; - - const struct spinand_manufacturer macronix_spinand_manufacturer = { - .id = SPINAND_MFR_MACRONIX, - .name = "Macronix", -+ .chips = macronix_spinand_table, -+ .nchips = ARRAY_SIZE(macronix_spinand_table), - .ops = ¯onix_spinand_manuf_ops, }; ---- a/drivers/mtd/nand/spi/micron.c -+++ b/drivers/mtd/nand/spi/micron.c -@@ -120,7 +120,8 @@ static int micron_8_ecc_get_status(struc - static const struct spinand_info micron_spinand_table[] = { - /* M79A 2Gb 3.3V */ -- SPINAND_INFO("MT29F2G01ABAGD", 0x24, -+ SPINAND_INFO("MT29F2G01ABAGD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24), - NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -130,7 +131,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M79A 2Gb 1.8V */ -- SPINAND_INFO("MT29F2G01ABBGD", 0x25, -+ SPINAND_INFO("MT29F2G01ABBGD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25), - NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -140,7 +142,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M78A 1Gb 3.3V */ -- SPINAND_INFO("MT29F1G01ABAFD", 0x14, -+ SPINAND_INFO("MT29F1G01ABAFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -150,7 +153,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M78A 1Gb 1.8V */ -- SPINAND_INFO("MT29F1G01ABAFD", 0x15, -+ SPINAND_INFO("MT29F1G01ABAFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -160,7 +164,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M79A 4Gb 3.3V */ -- SPINAND_INFO("MT29F4G01ADAGD", 0x36, -+ SPINAND_INFO("MT29F4G01ADAGD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x36), - NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 2), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -171,7 +176,8 @@ static const struct spinand_info micron_ - micron_8_ecc_get_status), - SPINAND_SELECT_TARGET(micron_select_target)), - /* M70A 4Gb 3.3V */ -- SPINAND_INFO("MT29F4G01ABAFD", 0x34, -+ SPINAND_INFO("MT29F4G01ABAFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x34), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -181,7 +187,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M70A 4Gb 1.8V */ -- SPINAND_INFO("MT29F4G01ABBFD", 0x35, -+ SPINAND_INFO("MT29F4G01ABBFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -191,7 +198,8 @@ static const struct spinand_info micron_ - SPINAND_ECCINFO(µn_8_ooblayout, - micron_8_ecc_get_status)), - /* M70A 8Gb 3.3V */ -- SPINAND_INFO("MT29F8G01ADAFD", 0x46, -+ SPINAND_INFO("MT29F8G01ADAFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x46), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 2), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -202,7 +210,8 @@ static const struct spinand_info micron_ - micron_8_ecc_get_status), - SPINAND_SELECT_TARGET(micron_select_target)), - /* M70A 8Gb 1.8V */ -- SPINAND_INFO("MT29F8G01ADBFD", 0x47, -+ SPINAND_INFO("MT29F8G01ADBFD", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x47), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 2), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -214,26 +223,6 @@ static const struct spinand_info micron_ - SPINAND_SELECT_TARGET(micron_select_target)), - }; - --static int micron_spinand_detect(struct spinand_device *spinand) --{ -- u8 *id = spinand->id.data; -- int ret; -- -- /* -- * Micron SPI NAND read ID need a dummy byte, -- * so the first byte in raw_id is dummy. -- */ -- if (id[1] != SPINAND_MFR_MICRON) -- return 0; -- -- ret = spinand_match_and_init(spinand, micron_spinand_table, -- ARRAY_SIZE(micron_spinand_table), id[2]); -- if (ret) -- return ret; -- -- return 1; --} -- - static int micron_spinand_init(struct spinand_device *spinand) - { - /* -@@ -248,12 +237,13 @@ static int micron_spinand_init(struct sp - } - - static const struct spinand_manufacturer_ops micron_spinand_manuf_ops = { -- .detect = micron_spinand_detect, - .init = micron_spinand_init, - }; - - const struct spinand_manufacturer micron_spinand_manufacturer = { - .id = SPINAND_MFR_MICRON, - .name = "Micron", -+ .chips = micron_spinand_table, -+ .nchips = ARRAY_SIZE(micron_spinand_table), - .ops = µn_spinand_manuf_ops, - }; ---- a/drivers/mtd/nand/spi/toshiba.c -+++ b/drivers/mtd/nand/spi/toshiba.c -@@ -111,7 +111,8 @@ static int tx58cxgxsxraix_ecc_get_status - - static const struct spinand_info toshiba_spinand_table[] = { - /* 3.3V 1Gb (1st generation) */ -- SPINAND_INFO("TC58CVG0S3HRAIG", 0xC2, -+ SPINAND_INFO("TC58CVG0S3HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xC2), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -121,7 +122,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 3.3V 2Gb (1st generation) */ -- SPINAND_INFO("TC58CVG1S3HRAIG", 0xCB, -+ SPINAND_INFO("TC58CVG1S3HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xCB), - NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -131,7 +133,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 3.3V 4Gb (1st generation) */ -- SPINAND_INFO("TC58CVG2S0HRAIG", 0xCD, -+ SPINAND_INFO("TC58CVG2S0HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xCD), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -141,7 +144,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 1Gb (1st generation) */ -- SPINAND_INFO("TC58CYG0S3HRAIG", 0xB2, -+ SPINAND_INFO("TC58CYG0S3HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xB2), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -151,7 +155,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 2Gb (1st generation) */ -- SPINAND_INFO("TC58CYG1S3HRAIG", 0xBB, -+ SPINAND_INFO("TC58CYG1S3HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xBB), - NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -161,7 +166,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 4Gb (1st generation) */ -- SPINAND_INFO("TC58CYG2S0HRAIG", 0xBD, -+ SPINAND_INFO("TC58CYG2S0HRAIG", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xBD), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -176,7 +182,8 @@ static const struct spinand_info toshiba - * QE_BIT. - */ - /* 3.3V 1Gb (2nd generation) */ -- SPINAND_INFO("TC58CVG0S3HRAIJ", 0xE2, -+ SPINAND_INFO("TC58CVG0S3HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE2), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -186,7 +193,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 3.3V 2Gb (2nd generation) */ -- SPINAND_INFO("TC58CVG1S3HRAIJ", 0xEB, -+ SPINAND_INFO("TC58CVG1S3HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xEB), - NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -196,7 +204,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 3.3V 4Gb (2nd generation) */ -- SPINAND_INFO("TC58CVG2S0HRAIJ", 0xED, -+ SPINAND_INFO("TC58CVG2S0HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xED), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -206,7 +215,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 3.3V 8Gb (2nd generation) */ -- SPINAND_INFO("TH58CVG3S0HRAIJ", 0xE4, -+ SPINAND_INFO("TH58CVG3S0HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4), - NAND_MEMORG(1, 4096, 256, 64, 4096, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -216,7 +226,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 1Gb (2nd generation) */ -- SPINAND_INFO("TC58CYG0S3HRAIJ", 0xD2, -+ SPINAND_INFO("TC58CYG0S3HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xD2), - NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -226,7 +237,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 2Gb (2nd generation) */ -- SPINAND_INFO("TC58CYG1S3HRAIJ", 0xDB, -+ SPINAND_INFO("TC58CYG1S3HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xDB), - NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -236,7 +248,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 4Gb (2nd generation) */ -- SPINAND_INFO("TC58CYG2S0HRAIJ", 0xDD, -+ SPINAND_INFO("TC58CYG2S0HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xDD), - NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -246,7 +259,8 @@ static const struct spinand_info toshiba - SPINAND_ECCINFO(&tx58cxgxsxraix_ooblayout, - tx58cxgxsxraix_ecc_get_status)), - /* 1.8V 8Gb (2nd generation) */ -- SPINAND_INFO("TH58CYG3S0HRAIJ", 0xD4, -+ SPINAND_INFO("TH58CYG3S0HRAIJ", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xD4), - NAND_MEMORG(1, 4096, 256, 64, 4096, 1, 1, 1), - NAND_ECCREQ(8, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -257,33 +271,13 @@ static const struct spinand_info toshiba - tx58cxgxsxraix_ecc_get_status)), - }; - --static int toshiba_spinand_detect(struct spinand_device *spinand) --{ -- u8 *id = spinand->id.data; -- int ret; -- -- /* -- * Toshiba SPI NAND read ID needs a dummy byte, -- * so the first byte in id is garbage. -- */ -- if (id[1] != SPINAND_MFR_TOSHIBA) -- return 0; -- -- ret = spinand_match_and_init(spinand, toshiba_spinand_table, -- ARRAY_SIZE(toshiba_spinand_table), -- id[2]); -- if (ret) -- return ret; -- -- return 1; --} -- - static const struct spinand_manufacturer_ops toshiba_spinand_manuf_ops = { -- .detect = toshiba_spinand_detect, - }; - - const struct spinand_manufacturer toshiba_spinand_manufacturer = { - .id = SPINAND_MFR_TOSHIBA, - .name = "Toshiba", -+ .chips = toshiba_spinand_table, -+ .nchips = ARRAY_SIZE(toshiba_spinand_table), - .ops = &toshiba_spinand_manuf_ops, - }; + static const struct spinand_manufacturer_ops gigadevice_spinand_manuf_ops = { --- a/drivers/mtd/nand/spi/winbond.c +++ b/drivers/mtd/nand/spi/winbond.c -@@ -19,6 +19,23 @@ +@@ -18,6 +18,23 @@ #define WINBOND_CFG_BUF_READ BIT(3) @@ -1373,7 +409,7 @@ Signed-off-by: Weijie Gao static SPINAND_OP_VARIANTS(read_cache_variants, SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), -@@ -35,6 +52,35 @@ static SPINAND_OP_VARIANTS(update_cache_ +@@ -34,6 +51,35 @@ static SPINAND_OP_VARIANTS(update_cache_ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), SPINAND_PROG_LOAD(false, 0, NULL, 0)); @@ -1409,9 +445,9 @@ Signed-off-by: Weijie Gao static int w25m02gv_ooblayout_ecc(struct mtd_info *mtd, int section, struct mtd_oob_region *region) { -@@ -78,8 +124,61 @@ static int w25m02gv_select_target(struct - return spi_mem_exec_op(spinand->slave, &op); - } +@@ -106,6 +152,58 @@ static const struct mtd_ooblayout_ops w2 + .rfree = w25n02kv_ooblayout_free, + }; +static int w25n01kv_ecc_get_status(struct spinand_device *spinand, + u8 status) @@ -1465,77 +501,32 @@ Signed-off-by: Weijie Gao + return -EINVAL; +} + - static const struct spinand_info winbond_spinand_table[] = { -- SPINAND_INFO("W25M02GV", 0xAB, -+ SPINAND_INFO("W25M02GV", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xab, 0x21), - NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 2), - NAND_ECCREQ(1, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -88,7 +187,17 @@ static const struct spinand_info winbond + static int w25n02kv_ecc_get_status(struct spinand_device *spinand, + u8 status) + { +@@ -163,6 +261,15 @@ static const struct spinand_info winbond + &update_cache_variants), 0, - SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL), - SPINAND_SELECT_TARGET(w25m02gv_select_target)), -- SPINAND_INFO("W25N01GV", 0xAA, + SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)), + SPINAND_INFO("W25N01KV", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae, 0x21), -+ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + 0, + SPINAND_ECCINFO(&w25n02kv_n04kv_ooblayout, w25n01kv_ecc_get_status)), -+ SPINAND_INFO("W25N01GV", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x21), - NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), - NAND_ECCREQ(1, 512), - SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -@@ -96,32 +205,30 @@ static const struct spinand_info winbond + SPINAND_INFO("W25N02KV", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x22), + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), +@@ -172,6 +279,16 @@ static const struct spinand_info winbond &update_cache_variants), 0, - SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)), --}; -- --/** -- * winbond_spinand_detect - initialize device related part in spinand_device -- * struct if it is a Winbond device. -- * @spinand: SPI NAND device structure -- */ --static int winbond_spinand_detect(struct spinand_device *spinand) --{ -- u8 *id = spinand->id.data; -- int ret; -- -- /* -- * Winbond SPI NAND read ID need a dummy byte, -- * so the first byte in raw_id is dummy. -+ SPINAND_INFO("W25N02KV", -+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x22), -+ NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1), -+ NAND_ECCREQ(4, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ 0, -+ SPINAND_ECCINFO(&w25n02kv_n04kv_ooblayout, -+ w25n02kv_n04kv_ecc_get_status)), -+ /* W25N04KV has 2-die(lun), however, it can select die automatically. -+ * Treat it as single die here and double block size. - */ -- if (id[1] != SPINAND_MFR_WINBOND) -- return 0; -- -- ret = spinand_match_and_init(spinand, winbond_spinand_table, -- ARRAY_SIZE(winbond_spinand_table), id[2]); -- if (ret) -- return ret; -- -- return 1; --} + SPINAND_ECCINFO(&w25n02kv_ooblayout, w25n02kv_ecc_get_status)), + SPINAND_INFO("W25N04KV", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x23), -+ NAND_MEMORG(1, 2048, 128, 64, 4096, 2, 1, 1), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, @@ -1543,162 +534,12 @@ Signed-off-by: Weijie Gao + 0, + SPINAND_ECCINFO(&w25n02kv_n04kv_ooblayout, + w25n02kv_n04kv_ecc_get_status)), -+}; - - static int winbond_spinand_init(struct spinand_device *spinand) - { -@@ -142,12 +249,13 @@ static int winbond_spinand_init(struct s - } - - static const struct spinand_manufacturer_ops winbond_spinand_manuf_ops = { -- .detect = winbond_spinand_detect, - .init = winbond_spinand_init, }; - const struct spinand_manufacturer winbond_spinand_manufacturer = { - .id = SPINAND_MFR_WINBOND, - .name = "Winbond", -+ .chips = winbond_spinand_table, -+ .nchips = ARRAY_SIZE(winbond_spinand_table), - .ops = &winbond_spinand_manuf_ops, - }; + static int winbond_spinand_init(struct spinand_device *spinand) --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h -@@ -39,15 +39,15 @@ - SPI_MEM_OP_NO_DUMMY, \ - SPI_MEM_OP_NO_DATA) - --#define SPINAND_READID_OP(ndummy, buf, len) \ -+#define SPINAND_READID_OP(naddr, ndummy, buf, len) \ - SPI_MEM_OP(SPI_MEM_OP_CMD(0x9f, 1), \ -- SPI_MEM_OP_NO_ADDR, \ -+ SPI_MEM_OP_ADDR(naddr, 0, 1), \ - SPI_MEM_OP_DUMMY(ndummy, 1), \ - SPI_MEM_OP_DATA_IN(len, buf, 1)) - - #define SPINAND_SET_FEATURE_OP(reg, valptr) \ - SPI_MEM_OP(SPI_MEM_OP_CMD(0x1f, 1), \ -- SPI_MEM_OP_ADDR(1, reg, 1), \ -+ SPI_MEM_OP_ADDR(1, reg, 1), \ - SPI_MEM_OP_NO_DUMMY, \ - SPI_MEM_OP_DATA_OUT(1, valptr, 1)) - -@@ -75,18 +75,36 @@ - SPI_MEM_OP_DUMMY(ndummy, 1), \ - SPI_MEM_OP_DATA_IN(len, buf, 1)) - -+#define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(fast, addr, ndummy, buf, len)\ -+ SPI_MEM_OP(SPI_MEM_OP_CMD(fast ? 0x0b : 0x03, 1), \ -+ SPI_MEM_OP_ADDR(3, addr, 1), \ -+ SPI_MEM_OP_DUMMY(ndummy, 1), \ -+ SPI_MEM_OP_DATA_IN(len, buf, 1)) -+ - #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len) \ - SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1), \ - SPI_MEM_OP_ADDR(2, addr, 1), \ - SPI_MEM_OP_DUMMY(ndummy, 1), \ - SPI_MEM_OP_DATA_IN(len, buf, 2)) - -+#define SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(addr, ndummy, buf, len) \ -+ SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1), \ -+ SPI_MEM_OP_ADDR(3, addr, 1), \ -+ SPI_MEM_OP_DUMMY(ndummy, 1), \ -+ SPI_MEM_OP_DATA_IN(len, buf, 2)) -+ - #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP(addr, ndummy, buf, len) \ - SPI_MEM_OP(SPI_MEM_OP_CMD(0x6b, 1), \ - SPI_MEM_OP_ADDR(2, addr, 1), \ - SPI_MEM_OP_DUMMY(ndummy, 1), \ - SPI_MEM_OP_DATA_IN(len, buf, 4)) - -+#define SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(addr, ndummy, buf, len) \ -+ SPI_MEM_OP(SPI_MEM_OP_CMD(0x6b, 1), \ -+ SPI_MEM_OP_ADDR(3, addr, 1), \ -+ SPI_MEM_OP_DUMMY(ndummy, 1), \ -+ SPI_MEM_OP_DATA_IN(len, buf, 4)) -+ - #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(addr, ndummy, buf, len) \ - SPI_MEM_OP(SPI_MEM_OP_CMD(0xbb, 1), \ - SPI_MEM_OP_ADDR(2, addr, 2), \ -@@ -153,37 +171,46 @@ struct spinand_device; - * @data: buffer containing the id bytes. Currently 4 bytes large, but can - * be extended if required - * @len: ID length -- * -- * struct_spinand_id->data contains all bytes returned after a READ_ID command, -- * including dummy bytes if the chip does not emit ID bytes right after the -- * READ_ID command. The responsibility to extract real ID bytes is left to -- * struct_manufacurer_ops->detect(). - */ - struct spinand_id { - u8 data[SPINAND_MAX_ID_LEN]; - int len; - }; - -+enum spinand_readid_method { -+ SPINAND_READID_METHOD_OPCODE, -+ SPINAND_READID_METHOD_OPCODE_ADDR, -+ SPINAND_READID_METHOD_OPCODE_DUMMY, -+}; -+ -+/** -+ * struct spinand_devid - SPI NAND device id structure -+ * @id: device id of current chip -+ * @len: number of bytes in device id -+ * @method: method to read chip id -+ * There are 3 possible variants: -+ * SPINAND_READID_METHOD_OPCODE: chip id is returned immediately -+ * after read_id opcode. -+ * SPINAND_READID_METHOD_OPCODE_ADDR: chip id is returned after -+ * read_id opcode + 1-byte address. -+ * SPINAND_READID_METHOD_OPCODE_DUMMY: chip id is returned after -+ * read_id opcode + 1 dummy byte. -+ */ -+struct spinand_devid { -+ const u8 *id; -+ const u8 len; -+ const enum spinand_readid_method method; -+}; -+ - /** - * struct manufacurer_ops - SPI NAND manufacturer specific operations -- * @detect: detect a SPI NAND device. Every time a SPI NAND device is probed -- * the core calls the struct_manufacurer_ops->detect() hook of each -- * registered manufacturer until one of them return 1. Note that -- * the first thing to check in this hook is that the manufacturer ID -- * in struct_spinand_device->id matches the manufacturer whose -- * ->detect() hook has been called. Should return 1 if there's a -- * match, 0 if the manufacturer ID does not match and a negative -- * error code otherwise. When true is returned, the core assumes -- * that properties of the NAND chip (spinand->base.memorg and -- * spinand->base.eccreq) have been filled - * @init: initialize a SPI NAND device - * @cleanup: cleanup a SPI NAND device - * - * Each SPI NAND manufacturer driver should implement this interface so that -- * NAND chips coming from this vendor can be detected and initialized properly. -+ * NAND chips coming from this vendor can be initialized properly. - */ - struct spinand_manufacturer_ops { -- int (*detect)(struct spinand_device *spinand); - int (*init)(struct spinand_device *spinand); - void (*cleanup)(struct spinand_device *spinand); - }; -@@ -192,15 +219,21 @@ struct spinand_manufacturer_ops { - * struct spinand_manufacturer - SPI NAND manufacturer instance - * @id: manufacturer ID - * @name: manufacturer name -+ * @devid_len: number of bytes in device ID -+ * @chips: supported SPI NANDs under current manufacturer -+ * @nchips: number of SPI NANDs available in chips array - * @ops: manufacturer operations - */ - struct spinand_manufacturer { - u8 id; - char *name; -+ const struct spinand_info *chips; -+ const size_t nchips; - const struct spinand_manufacturer_ops *ops; +@@ -245,6 +245,7 @@ struct spinand_manufacturer { }; /* SPI NAND manufacturers */ @@ -1706,39 +547,3 @@ Signed-off-by: Weijie Gao extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; extern const struct spinand_manufacturer macronix_spinand_manufacturer; extern const struct spinand_manufacturer micron_spinand_manufacturer; -@@ -268,7 +301,7 @@ struct spinand_ecc_info { - */ - struct spinand_info { - const char *model; -- u8 devid; -+ struct spinand_devid devid; - u32 flags; - struct nand_memory_organization memorg; - struct nand_ecc_req eccreq; -@@ -282,6 +315,13 @@ struct spinand_info { - unsigned int target); - }; - -+#define SPINAND_ID(__method, ...) \ -+ { \ -+ .id = (const u8[]){ __VA_ARGS__ }, \ -+ .len = sizeof((u8[]){ __VA_ARGS__ }), \ -+ .method = __method, \ -+ } -+ - #define SPINAND_INFO_OP_VARIANTS(__read, __write, __update) \ - { \ - .read_cache = __read, \ -@@ -440,9 +480,10 @@ static inline void spinand_set_ofnode(st - } - #endif /* __UBOOT__ */ - --int spinand_match_and_init(struct spinand_device *dev, -+int spinand_match_and_init(struct spinand_device *spinand, - const struct spinand_info *table, -- unsigned int table_size, u8 devid); -+ unsigned int table_size, -+ enum spinand_readid_method rdid_method); - - int spinand_upd_cfg(struct spinand_device *spinand, u8 mask, u8 val); - int spinand_select_target(struct spinand_device *spinand, unsigned int target); diff --git a/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch b/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch index 0c68f429c6b0c4..5c90e24ebf51e7 100644 --- a/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch +++ b/package/boot/uboot-mediatek/patches/100-23-mmc-mtk-sd-add-support-to-display-verbose-error-log.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig -@@ -820,6 +820,14 @@ config MMC_MTK +@@ -815,6 +815,14 @@ config MMC_MTK This is needed if support for any SD/SDIO/MMC devices is required. If unsure, say N. @@ -32,7 +32,7 @@ Signed-off-by: Weijie Gao config FSL_SDHC_V2_3 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile -@@ -83,3 +83,7 @@ obj-$(CONFIG_RENESAS_SDHI) += tmio-comm +@@ -82,3 +82,7 @@ obj-$(CONFIG_RENESAS_SDHI) += tmio-comm obj-$(CONFIG_MMC_BCM2835) += bcm2835_sdhost.o obj-$(CONFIG_MMC_MTK) += mtk-sd.o obj-$(CONFIG_MMC_SDHCI_F_SDH30) += f_sdh30.o @@ -42,7 +42,7 @@ Signed-off-by: Weijie Gao +endif --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c -@@ -778,18 +778,24 @@ static int msdc_ops_send_cmd(struct udev +@@ -779,18 +779,24 @@ static int msdc_ops_send_cmd(struct udev if (cmd_ret && !(cmd_ret == -EIO && (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK || diff --git a/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch index 98c81acdcfdb60..fb8d15ddf9b03b 100644 --- a/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch +++ b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch @@ -14,7 +14,7 @@ Signed-off-by: Weijie Gao --- a/env/Kconfig +++ b/env/Kconfig -@@ -675,6 +675,12 @@ config ENV_UBI_VOLUME_REDUND +@@ -689,6 +689,12 @@ config ENV_UBI_VOLUME_REDUND help Name of the redundant volume that you want to store the environment in. diff --git a/package/boot/uboot-mediatek/patches/100-27-mtd-ubi-add-support-for-UBI-end-of-filesystem-marker.patch b/package/boot/uboot-mediatek/patches/100-27-mtd-ubi-add-support-for-UBI-end-of-filesystem-marker.patch index cd1794f0d119e6..9c83e6cc25daf3 100644 --- a/package/boot/uboot-mediatek/patches/100-27-mtd-ubi-add-support-for-UBI-end-of-filesystem-marker.patch +++ b/package/boot/uboot-mediatek/patches/100-27-mtd-ubi-add-support-for-UBI-end-of-filesystem-marker.patch @@ -15,7 +15,7 @@ Signed-off-by: Weijie Gao --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c -@@ -802,6 +802,13 @@ out_unlock: +@@ -803,6 +803,13 @@ out_unlock: return err; } @@ -29,7 +29,7 @@ Signed-off-by: Weijie Gao /** * scan_peb - scan and process UBI headers of a PEB. * @ubi: UBI device description object -@@ -832,9 +839,21 @@ static int scan_peb(struct ubi_device *u +@@ -833,9 +840,21 @@ static int scan_peb(struct ubi_device *u return 0; } @@ -56,7 +56,7 @@ Signed-off-by: Weijie Gao break; --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h -@@ -745,6 +745,7 @@ struct ubi_attach_info { +@@ -746,6 +746,7 @@ struct ubi_attach_info { int mean_ec; uint64_t ec_sum; int ec_count; diff --git a/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch b/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch index b561a799444108..f22449ae76fd0c 100644 --- a/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch +++ b/package/boot/uboot-mediatek/patches/100-29-board-mediatek-wire-up-NMBM-support.patch @@ -24,7 +24,7 @@ Subject: [PATCH] board: mediatek: wire-up NMBM support DECLARE_GLOBAL_DATA_PTR; int board_init(void) -@@ -24,3 +29,36 @@ int board_late_init(void) +@@ -23,3 +28,36 @@ int board_late_init(void) env_relocate(); return 0; } diff --git a/package/boot/uboot-mediatek/patches/101-01-arm-mediatek-retrieve-ram_base-from-dts-node-for-arm.patch b/package/boot/uboot-mediatek/patches/101-01-arm-mediatek-retrieve-ram_base-from-dts-node-for-arm.patch deleted file mode 100644 index 645b7801c8b8e0..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-01-arm-mediatek-retrieve-ram_base-from-dts-node-for-arm.patch +++ /dev/null @@ -1,297 +0,0 @@ -From 63336ec7fd7d480ac58a91f3b20d08bf1b3a13ad Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:15:41 +0800 -Subject: [PATCH 01/29] arm: mediatek: retrieve ram_base from dts node for - armv8 platform - -Now we use fdtdec_setup_mem_size_base() to get DRAM base from fdt ram node -and update gd->ram_base. CFG_SYS_SDRAM_BASE is unused and will be removed. - -Also, since mt7622 always passes fdt to linux kernel, there's no need to -assign value to gd->bd->bi_boot_params. - -Signed-off-by: Weijie Gao ---- - arch/arm/dts/mt7981-emmc-rfb.dts | 5 +++++ - arch/arm/dts/mt7981-rfb.dts | 5 +++++ - arch/arm/dts/mt7981-sd-rfb.dts | 5 +++++ - arch/arm/dts/mt7986a-bpi-r3-sd.dts | 5 +++++ - arch/arm/dts/mt7986a-rfb.dts | 5 +++++ - arch/arm/dts/mt7986a-sd-rfb.dts | 5 +++++ - arch/arm/dts/mt7986b-rfb.dts | 5 +++++ - arch/arm/dts/mt7986b-sd-rfb.dts | 5 +++++ - arch/arm/mach-mediatek/mt7622/init.c | 13 +++++++++---- - arch/arm/mach-mediatek/mt7981/init.c | 11 +++++++++-- - arch/arm/mach-mediatek/mt7986/init.c | 11 +++++++++-- - board/mediatek/mt7622/mt7622_rfb.c | 1 - - include/configs/mt7622.h | 10 ---------- - include/configs/mt7981.h | 9 --------- - include/configs/mt7986.h | 9 --------- - 15 files changed, 67 insertions(+), 37 deletions(-) - ---- a/arch/arm/dts/mt7981-emmc-rfb.dts -+++ b/arch/arm/dts/mt7981-emmc-rfb.dts -@@ -18,6 +18,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/dts/mt7981-rfb.dts -+++ b/arch/arm/dts/mt7981-rfb.dts -@@ -17,6 +17,11 @@ - stdout-path = &uart0; - tick-timer = &timer0; - }; -+ -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; - }; - - &uart0 { ---- a/arch/arm/dts/mt7981-sd-rfb.dts -+++ b/arch/arm/dts/mt7981-sd-rfb.dts -@@ -18,6 +18,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/dts/mt7986a-bpi-r3-sd.dts -+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts -@@ -19,6 +19,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x80000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/dts/mt7986a-rfb.dts -+++ b/arch/arm/dts/mt7986a-rfb.dts -@@ -18,6 +18,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_1p8v: regulator-1p8v { - compatible = "regulator-fixed"; - regulator-name = "fixed-1.8V"; ---- a/arch/arm/dts/mt7986a-sd-rfb.dts -+++ b/arch/arm/dts/mt7986a-sd-rfb.dts -@@ -19,6 +19,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/dts/mt7986b-rfb.dts -+++ b/arch/arm/dts/mt7986b-rfb.dts -@@ -18,6 +18,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/dts/mt7986b-sd-rfb.dts -+++ b/arch/arm/dts/mt7986b-sd-rfb.dts -@@ -19,6 +19,11 @@ - tick-timer = &timer0; - }; - -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0x40000000 0x10000000>; -+ }; -+ - reg_3p3v: regulator-3p3v { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; ---- a/arch/arm/mach-mediatek/mt7622/init.c -+++ b/arch/arm/mach-mediatek/mt7622/init.c -@@ -4,11 +4,14 @@ - * Author: Sam Shih - */ - --#include - #include - #include - #include --#include -+#include -+#include -+#include -+ -+DECLARE_GLOBAL_DATA_PTR; - - int print_cpuinfo(void) - { -@@ -20,11 +23,13 @@ int dram_init(void) - { - int ret; - -- ret = fdtdec_setup_memory_banksize(); -+ ret = fdtdec_setup_mem_size_base(); - if (ret) - return ret; -- return fdtdec_setup_mem_size_base(); - -+ gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_2G); -+ -+ return 0; - } - - void reset_cpu(void) ---- a/arch/arm/mach-mediatek/mt7981/init.c -+++ b/arch/arm/mach-mediatek/mt7981/init.c -@@ -4,18 +4,25 @@ - * Author: Sam Shih - */ - --#include -+#include - #include - #include - #include - #include -+#include - #include - - DECLARE_GLOBAL_DATA_PTR; - - int dram_init(void) - { -- gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, SZ_2G); -+ int ret; -+ -+ ret = fdtdec_setup_mem_size_base(); -+ if (ret) -+ return ret; -+ -+ gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_1G); - - return 0; - } ---- a/arch/arm/mach-mediatek/mt7986/init.c -+++ b/arch/arm/mach-mediatek/mt7986/init.c -@@ -4,18 +4,25 @@ - * Author: Sam Shih - */ - --#include -+#include - #include - #include - #include - #include -+#include - #include - - DECLARE_GLOBAL_DATA_PTR; - - int dram_init(void) - { -- gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, SZ_2G); -+ int ret; -+ -+ ret = fdtdec_setup_mem_size_base(); -+ if (ret) -+ return ret; -+ -+ gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_2G); - - return 0; - } ---- a/board/mediatek/mt7622/mt7622_rfb.c -+++ b/board/mediatek/mt7622/mt7622_rfb.c -@@ -19,7 +19,6 @@ DECLARE_GLOBAL_DATA_PTR; - - int board_init(void) - { -- gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100; - return 0; - } - ---- a/include/configs/mt7622.h -+++ b/include/configs/mt7622.h -@@ -9,14 +9,4 @@ - #ifndef __MT7622_H - #define __MT7622_H - --/* Uboot definition */ --#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE -- --/* SPL -> Uboot */ --#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE --/* DRAM */ --#define CFG_SYS_SDRAM_BASE 0x40000000 -- --/* Ethernet */ -- - #endif ---- a/include/configs/mt7981.h -+++ b/include/configs/mt7981.h -@@ -9,13 +9,4 @@ - #ifndef __MT7981_H - #define __MT7981_H - --/* Uboot definition */ --#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE -- --/* SPL -> Uboot */ --#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE -- --/* DRAM */ --#define CFG_SYS_SDRAM_BASE 0x40000000 -- - #endif ---- a/include/configs/mt7986.h -+++ b/include/configs/mt7986.h -@@ -9,13 +9,4 @@ - #ifndef __MT7986_H - #define __MT7986_H - --/* Uboot definition */ --#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE -- --/* SPL -> Uboot */ --#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE -- --/* DRAM */ --#define CFG_SYS_SDRAM_BASE 0x40000000 -- - #endif diff --git a/package/boot/uboot-mediatek/patches/101-02-board-mediatek-update-config-headers.patch b/package/boot/uboot-mediatek/patches/101-02-board-mediatek-update-config-headers.patch deleted file mode 100644 index b64ee15171fa3d..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-02-board-mediatek-update-config-headers.patch +++ /dev/null @@ -1,129 +0,0 @@ -From df3a0091b249ea82198ea019d145d05a7cf49c0d Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:15:47 +0800 -Subject: [PATCH 02/29] board: mediatek: update config headers - -Remove unused information from include/configs/mtxxxx.h - -Signed-off-by: Weijie Gao ---- - include/configs/mt7620.h | 3 +-- - include/configs/mt7621.h | 6 ++---- - include/configs/mt7623.h | 8 -------- - include/configs/mt7628.h | 5 ++--- - include/configs/mt7629.h | 13 +------------ - 5 files changed, 6 insertions(+), 29 deletions(-) - ---- a/include/configs/mt7620.h -+++ b/include/configs/mt7620.h -@@ -10,10 +10,9 @@ - - #define CFG_SYS_SDRAM_BASE 0x80000000 - --#define CFG_SYS_INIT_SP_OFFSET 0x400000 -+#define CFG_SYS_INIT_SP_OFFSET 0x400000 - - /* SPL */ -- - #define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE - - /* Dummy value */ ---- a/include/configs/mt7621.h -+++ b/include/configs/mt7621.h -@@ -12,13 +12,11 @@ - - #define CFG_MAX_MEM_MAPPED 0x1c000000 - --#define CFG_SYS_INIT_SP_OFFSET 0x800000 -+#define CFG_SYS_INIT_SP_OFFSET 0x800000 - - /* MMC */ - #define MMC_SUPPORTS_TUNING - --/* NAND */ -- - /* Serial SPL */ - #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_SERIAL) - #define CFG_SYS_NS16550_CLK 50000000 -@@ -26,7 +24,7 @@ - #endif - - /* Serial common */ --#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \ -+#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \ - 230400, 460800, 921600 } - - /* Dummy value */ ---- a/include/configs/mt7623.h -+++ b/include/configs/mt7623.h -@@ -11,12 +11,6 @@ - - #include - --/* Miscellaneous configurable options */ -- --/* Environment */ -- --/* Preloader -> Uboot */ -- - /* MMC */ - #define MMC_SUPPORTS_TUNING - -@@ -32,8 +26,6 @@ - "fdt_addr_r=" FDT_HIGH "\0" \ - "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" - --/* Ethernet */ -- - #ifdef CONFIG_DISTRO_DEFAULTS - - #define BOOT_TARGET_DEVICES(func) \ ---- a/include/configs/mt7628.h -+++ b/include/configs/mt7628.h -@@ -10,7 +10,7 @@ - - #define CFG_SYS_SDRAM_BASE 0x80000000 - --#define CFG_SYS_INIT_SP_OFFSET 0x80000 -+#define CFG_SYS_INIT_SP_OFFSET 0x80000 - - /* Serial SPL */ - #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_SERIAL) -@@ -19,11 +19,10 @@ - #endif - - /* Serial common */ --#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \ -+#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \ - 230400, 460800, 921600 } - - /* SPL */ -- - #define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE - - /* Dummy value */ ---- a/include/configs/mt7629.h -+++ b/include/configs/mt7629.h -@@ -9,21 +9,10 @@ - #ifndef __MT7629_H - #define __MT7629_H - --#include -- --/* Miscellaneous configurable options */ -- --/* Environment */ -- -+/* SPL */ - #define CFG_SYS_UBOOT_BASE (0x30000000 + CONFIG_SPL_PAD_TO) - --/* SPL -> Uboot */ -- --/* UBoot -> Kernel */ -- - /* DRAM */ - #define CFG_SYS_SDRAM_BASE 0x40000000 - --/* Ethernet */ -- - #endif diff --git a/package/boot/uboot-mediatek/patches/101-03-spi-mtk_spim-get-spi-clk-rate-only-once.patch b/package/boot/uboot-mediatek/patches/101-03-spi-mtk_spim-get-spi-clk-rate-only-once.patch deleted file mode 100644 index 323bb249332ccb..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-03-spi-mtk_spim-get-spi-clk-rate-only-once.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0d6d8a408f80358dd47984320ea9c65e555ac4c9 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:15:54 +0800 -Subject: [PATCH 03/29] spi: mtk_spim: get spi clk rate only once - -We don't really need to switch clk rate during operating SPIM controller. -Get clk rate only once at driver probing. - -Signed-off-by: SkyLake.Huang -Signed-off-by: Weijie Gao -Reviewed-by: Jagan Teki ---- - drivers/spi/mtk_spim.c | 21 +++++++++++++-------- - 1 file changed, 13 insertions(+), 8 deletions(-) - ---- a/drivers/spi/mtk_spim.c -+++ b/drivers/spi/mtk_spim.c -@@ -137,6 +137,8 @@ struct mtk_spim_capability { - * @state: Controller state - * @sel_clk: Pad clock - * @spi_clk: Core clock -+ * @pll_clk_rate: Controller's PLL source clock rate, which is different -+ * from SPI bus clock rate - * @xfer_len: Current length of data for transfer - * @hw_cap: Controller capabilities - * @tick_dly: Used to postpone SPI sampling time -@@ -149,6 +151,7 @@ struct mtk_spim_priv { - void __iomem *base; - u32 state; - struct clk sel_clk, spi_clk; -+ u32 pll_clk_rate; - u32 xfer_len; - struct mtk_spim_capability hw_cap; - u32 tick_dly; -@@ -253,11 +256,10 @@ static int mtk_spim_hw_init(struct spi_s - static void mtk_spim_prepare_transfer(struct mtk_spim_priv *priv, - u32 speed_hz) - { -- u32 spi_clk_hz, div, sck_time, cs_time, reg_val; -+ u32 div, sck_time, cs_time, reg_val; - -- spi_clk_hz = clk_get_rate(&priv->spi_clk); -- if (speed_hz <= spi_clk_hz / 4) -- div = DIV_ROUND_UP(spi_clk_hz, speed_hz); -+ if (speed_hz <= priv->pll_clk_rate / 4) -+ div = DIV_ROUND_UP(priv->pll_clk_rate, speed_hz); - else - div = 4; - -@@ -404,7 +406,7 @@ static int mtk_spim_transfer_wait(struct - { - struct udevice *bus = dev_get_parent(slave->dev); - struct mtk_spim_priv *priv = dev_get_priv(bus); -- u32 sck_l, sck_h, spi_bus_clk, clk_count, reg; -+ u32 sck_l, sck_h, clk_count, reg; - ulong us = 1; - int ret = 0; - -@@ -413,12 +415,11 @@ static int mtk_spim_transfer_wait(struct - else - clk_count = op->data.nbytes; - -- spi_bus_clk = clk_get_rate(&priv->spi_clk); - sck_l = readl(priv->base + SPI_CFG2_REG) >> SPI_CFG2_SCK_LOW_OFFSET; - sck_h = readl(priv->base + SPI_CFG2_REG) & SPI_CFG2_SCK_HIGH_MASK; -- do_div(spi_bus_clk, sck_l + sck_h + 2); -+ do_div(priv->pll_clk_rate, sck_l + sck_h + 2); - -- us = CLK_TO_US(spi_bus_clk, clk_count * 8); -+ us = CLK_TO_US(priv->pll_clk_rate, clk_count * 8); - us += 1000 * 1000; /* 1s tolerance */ - - if (us > UINT_MAX) -@@ -662,6 +663,10 @@ static int mtk_spim_probe(struct udevice - clk_enable(&priv->sel_clk); - clk_enable(&priv->spi_clk); - -+ priv->pll_clk_rate = clk_get_rate(&priv->spi_clk); -+ if (priv->pll_clk_rate == 0) -+ return -EINVAL; -+ - return 0; - } - diff --git a/package/boot/uboot-mediatek/patches/101-04-spi-mtk_spim-clear-IRQ-enable-bits.patch b/package/boot/uboot-mediatek/patches/101-04-spi-mtk_spim-clear-IRQ-enable-bits.patch deleted file mode 100644 index e8577f63bf1f41..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-04-spi-mtk_spim-clear-IRQ-enable-bits.patch +++ /dev/null @@ -1,35 +0,0 @@ -From a7b630f02bb12f71f23866aee6f9a1a07497d475 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:02 +0800 -Subject: [PATCH 04/29] spi: mtk_spim: clear IRQ enable bits - -In u-boot we don't use IRQ. Instead, we poll busy bit in SPI_STATUS. - -However these IRQ enable bits may be set in previous boot stage (BootROM). - -If we leave these bits not cleared, although u-boot has disabled IRQ and -nothing will happen, the linux kernel may encounter panic during -initializing the spim driver due to IRQ event happens before IRQ handler -is properly setup. - -This patch clear IRQ bits to prevent this from happening. - -Signed-off-by: SkyLake.Huang -Signed-off-by: Weijie Gao -Reviewed-by: Jagan Teki ---- - drivers/spi/mtk_spim.c | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/drivers/spi/mtk_spim.c -+++ b/drivers/spi/mtk_spim.c -@@ -242,6 +242,9 @@ static int mtk_spim_hw_init(struct spi_s - reg_val &= ~SPI_CMD_SAMPLE_SEL; - } - -+ /* Disable interrupt enable for pause mode & normal mode */ -+ reg_val &= ~(SPI_CMD_PAUSE_IE | SPI_CMD_FINISH_IE); -+ - /* disable dma mode */ - reg_val &= ~(SPI_CMD_TX_DMA | SPI_CMD_RX_DMA); - diff --git a/package/boot/uboot-mediatek/patches/101-05-serial-mtk-initial-priv-data-before-using.patch b/package/boot/uboot-mediatek/patches/101-05-serial-mtk-initial-priv-data-before-using.patch deleted file mode 100644 index 6f805765c1fdfb..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-05-serial-mtk-initial-priv-data-before-using.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 73060da8b54e74c51ef6c1fd31c4fac6ad6b8d0e Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:07 +0800 -Subject: [PATCH 05/29] serial: mtk: initial priv data before using - -This patch ensures driver private data being fully initialized in -_debug_uart_init which is not covered by .priv_auto ops. - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao -Reviewed-by: Stefan Roese ---- - drivers/serial/serial_mtk.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/serial/serial_mtk.c -+++ b/drivers/serial/serial_mtk.c -@@ -439,6 +439,7 @@ static inline void _debug_uart_init(void - { - struct mtk_serial_priv priv; - -+ memset(&priv, 0, sizeof(struct mtk_serial_priv)); - priv.regs = (void *) CONFIG_VAL(DEBUG_UART_BASE); - priv.fixed_clk_rate = CONFIG_DEBUG_UART_CLOCK; - diff --git a/package/boot/uboot-mediatek/patches/101-06-reset-mediatek-check-malloc-return-valaue-before-use.patch b/package/boot/uboot-mediatek/patches/101-06-reset-mediatek-check-malloc-return-valaue-before-use.patch deleted file mode 100644 index b319f5e27eb61e..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-06-reset-mediatek-check-malloc-return-valaue-before-use.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 06e6d224f7d564a34407eba21b51797da7f22628 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:11 +0800 -Subject: [PATCH 06/29] reset: mediatek: check malloc return valaue before use - -This patch add missing return value check for allocating the driver's -private data. -ENOMEM will be returned if malloc() fails. - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - drivers/reset/reset-mediatek.c | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/drivers/reset/reset-mediatek.c -+++ b/drivers/reset/reset-mediatek.c -@@ -79,6 +79,9 @@ int mediatek_reset_bind(struct udevice * - return ret; - - priv = malloc(sizeof(struct mediatek_reset_priv)); -+ if (!priv) -+ return -ENOMEM; -+ - priv->regofs = regofs; - priv->nr_resets = num_regs * 32; - dev_set_priv(rst_dev, priv); diff --git a/package/boot/uboot-mediatek/patches/101-07-i2c-mediatek-fix-I2C-usability-for-MT7981.patch b/package/boot/uboot-mediatek/patches/101-07-i2c-mediatek-fix-I2C-usability-for-MT7981.patch deleted file mode 100644 index dd00104c391ec2..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-07-i2c-mediatek-fix-I2C-usability-for-MT7981.patch +++ /dev/null @@ -1,125 +0,0 @@ -From 77898faf6ce56eb08109cdb853f074bad5acee55 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:15 +0800 -Subject: [PATCH 07/29] i2c: mediatek: fix I2C usability for MT7981 - -MT7981 actually uses MediaTek I2C controller v3 instead of v1. -This patch adds support for I2C controller v3 fix fixes the I2C usability -for MT7981. - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - drivers/i2c/mtk_i2c.c | 45 +++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 43 insertions(+), 2 deletions(-) - ---- a/drivers/i2c/mtk_i2c.c -+++ b/drivers/i2c/mtk_i2c.c -@@ -183,9 +183,36 @@ static const uint mt_i2c_regs_v2[] = { - [REG_DCM_EN] = 0xf88, - }; - -+static const uint mt_i2c_regs_v3[] = { -+ [REG_PORT] = 0x0, -+ [REG_INTR_MASK] = 0x8, -+ [REG_INTR_STAT] = 0xc, -+ [REG_CONTROL] = 0x10, -+ [REG_TRANSFER_LEN] = 0x14, -+ [REG_TRANSAC_LEN] = 0x18, -+ [REG_DELAY_LEN] = 0x1c, -+ [REG_TIMING] = 0x20, -+ [REG_START] = 0x24, -+ [REG_EXT_CONF] = 0x28, -+ [REG_LTIMING] = 0x2c, -+ [REG_HS] = 0x30, -+ [REG_IO_CONFIG] = 0x34, -+ [REG_FIFO_ADDR_CLR] = 0x38, -+ [REG_TRANSFER_LEN_AUX] = 0x44, -+ [REG_CLOCK_DIV] = 0x48, -+ [REG_SOFTRESET] = 0x50, -+ [REG_SLAVE_ADDR] = 0x94, -+ [REG_DEBUGSTAT] = 0xe4, -+ [REG_DEBUGCTRL] = 0xe8, -+ [REG_FIFO_STAT] = 0xf4, -+ [REG_FIFO_THRESH] = 0xf8, -+ [REG_DCM_EN] = 0xf88, -+}; -+ - struct mtk_i2c_soc_data { - const uint *regs; - uint dma_sync: 1; -+ uint ltiming_adjust: 1; - }; - - struct mtk_i2c_priv { -@@ -401,6 +428,10 @@ static int mtk_i2c_set_speed(struct udev - (sample_cnt << HS_SAMPLE_OFFSET) | - (step_cnt << HS_STEP_OFFSET); - i2c_writel(priv, REG_HS, high_speed_reg); -+ if (priv->soc_data->ltiming_adjust) { -+ timing_reg = (sample_cnt << 12) | (step_cnt << 9); -+ i2c_writel(priv, REG_LTIMING, timing_reg); -+ } - } else { - ret = mtk_i2c_calculate_speed(clk_src, priv->speed, - &step_cnt, &sample_cnt); -@@ -412,7 +443,12 @@ static int mtk_i2c_set_speed(struct udev - high_speed_reg = I2C_TIME_CLR_VALUE; - i2c_writel(priv, REG_TIMING, timing_reg); - i2c_writel(priv, REG_HS, high_speed_reg); -+ if (priv->soc_data->ltiming_adjust) { -+ timing_reg = (sample_cnt << 6) | step_cnt; -+ i2c_writel(priv, REG_LTIMING, timing_reg); -+ } - } -+ - exit: - if (mtk_i2c_clk_disable(priv)) - return log_msg_ret("set_speed disable clk", -1); -@@ -725,7 +761,6 @@ static int mtk_i2c_probe(struct udevice - return log_msg_ret("probe enable clk", -1); - - mtk_i2c_init_hw(priv); -- - if (mtk_i2c_clk_disable(priv)) - return log_msg_ret("probe disable clk", -1); - -@@ -750,31 +785,37 @@ static int mtk_i2c_deblock(struct udevic - static const struct mtk_i2c_soc_data mt76xx_soc_data = { - .regs = mt_i2c_regs_v1, - .dma_sync = 0, -+ .ltiming_adjust = 0, - }; - - static const struct mtk_i2c_soc_data mt7981_soc_data = { -- .regs = mt_i2c_regs_v1, -+ .regs = mt_i2c_regs_v3, - .dma_sync = 1, -+ .ltiming_adjust = 1, - }; - - static const struct mtk_i2c_soc_data mt7986_soc_data = { - .regs = mt_i2c_regs_v1, - .dma_sync = 1, -+ .ltiming_adjust = 0, - }; - - static const struct mtk_i2c_soc_data mt8183_soc_data = { - .regs = mt_i2c_regs_v2, - .dma_sync = 1, -+ .ltiming_adjust = 0, - }; - - static const struct mtk_i2c_soc_data mt8518_soc_data = { - .regs = mt_i2c_regs_v1, - .dma_sync = 0, -+ .ltiming_adjust = 0, - }; - - static const struct mtk_i2c_soc_data mt8512_soc_data = { - .regs = mt_i2c_regs_v1, - .dma_sync = 1, -+ .ltiming_adjust = 0, - }; - - static const struct dm_i2c_ops mtk_i2c_ops = { diff --git a/package/boot/uboot-mediatek/patches/101-08-arm-dts-enable-i2c-support-for-MediaTek-MT7981.patch b/package/boot/uboot-mediatek/patches/101-08-arm-dts-enable-i2c-support-for-MediaTek-MT7981.patch deleted file mode 100644 index 77c4023493ad96..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-08-arm-dts-enable-i2c-support-for-MediaTek-MT7981.patch +++ /dev/null @@ -1,36 +0,0 @@ -From e9467f40d4327cfcb80944a0f12ae195b0d7cd40 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:19 +0800 -Subject: [PATCH 08/29] arm: dts: enable i2c support for MediaTek MT7981 - -This patch enables i2c support for MediaTek MT7981 - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - arch/arm/dts/mt7981.dtsi | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - ---- a/arch/arm/dts/mt7981.dtsi -+++ b/arch/arm/dts/mt7981.dtsi -@@ -181,6 +181,20 @@ - status = "disabled"; - }; - -+ i2c0: i2c@11007000 { -+ compatible = "mediatek,mt7981-i2c"; -+ reg = <0x11007000 0x1000>, -+ <0x10217080 0x80>; -+ interrupts = ; -+ clock-div = <1>; -+ clocks = <&infracfg_ao CK_INFRA_I2CO_CK>, -+ <&infracfg_ao CK_INFRA_AP_DMA_CK>; -+ clock-names = "main", "dma"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "disabled"; -+ }; -+ - uart0: serial@11002000 { - compatible = "mediatek,hsuart"; - reg = <0x11002000 0x400>; diff --git a/package/boot/uboot-mediatek/patches/101-09-pwm-mtk-add-support-for-MediaTek-MT7988-SoC.patch b/package/boot/uboot-mediatek/patches/101-09-pwm-mtk-add-support-for-MediaTek-MT7988-SoC.patch deleted file mode 100644 index 6ef62811cb1fa9..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-09-pwm-mtk-add-support-for-MediaTek-MT7988-SoC.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 646dab4a8e853b2d0789fa2ff64e7c48f5396cfa Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:24 +0800 -Subject: [PATCH 09/29] pwm: mtk: add support for MediaTek MT7988 SoC - -This patch adds PWM support for MediaTek MT7988 SoC. - -Signed-off-by: Weijie Gao ---- - drivers/pwm/pwm-mtk.c | 7 +++++++ - 1 file changed, 7 insertions(+) - ---- a/drivers/pwm/pwm-mtk.c -+++ b/drivers/pwm/pwm-mtk.c -@@ -205,12 +205,19 @@ static const struct mtk_pwm_soc mt7986_d - .reg_ver = PWM_REG_V1, - }; - -+static const struct mtk_pwm_soc mt7988_data = { -+ .num_pwms = 8, -+ .pwm45_fixup = false, -+ .reg_ver = PWM_REG_V2, -+}; -+ - static const struct udevice_id mtk_pwm_ids[] = { - { .compatible = "mediatek,mt7622-pwm", .data = (ulong)&mt7622_data }, - { .compatible = "mediatek,mt7623-pwm", .data = (ulong)&mt7623_data }, - { .compatible = "mediatek,mt7629-pwm", .data = (ulong)&mt7629_data }, - { .compatible = "mediatek,mt7981-pwm", .data = (ulong)&mt7981_data }, - { .compatible = "mediatek,mt7986-pwm", .data = (ulong)&mt7986_data }, -+ { .compatible = "mediatek,mt7988-pwm", .data = (ulong)&mt7988_data }, - { } - }; - diff --git a/package/boot/uboot-mediatek/patches/101-10-clk-mediatek-add-clock-driver-support-for-MediaTek-M.patch b/package/boot/uboot-mediatek/patches/101-10-clk-mediatek-add-clock-driver-support-for-MediaTek-M.patch deleted file mode 100644 index 12eda828fa9b9e..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-10-clk-mediatek-add-clock-driver-support-for-MediaTek-M.patch +++ /dev/null @@ -1,1505 +0,0 @@ -From 94306126baa215c39e9fd5328550586dedf00230 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:28 +0800 -Subject: [PATCH 10/29] clk: mediatek: add clock driver support for MediaTek - MT7988 SoC - -This patch adds clock driver support for MediaTek MT7988 SoC - -Signed-off-by: Weijie Gao ---- - drivers/clk/mediatek/Makefile | 1 + - drivers/clk/mediatek/clk-mt7988.c | 1123 ++++++++++++++++++++++++ - include/dt-bindings/clock/mt7988-clk.h | 349 ++++++++ - 3 files changed, 1473 insertions(+) - create mode 100644 drivers/clk/mediatek/clk-mt7988.c - create mode 100644 include/dt-bindings/clock/mt7988-clk.h - ---- a/drivers/clk/mediatek/Makefile -+++ b/drivers/clk/mediatek/Makefile -@@ -9,6 +9,7 @@ obj-$(CONFIG_TARGET_MT7622) += clk-mt762 - obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o - obj-$(CONFIG_TARGET_MT7986) += clk-mt7986.o - obj-$(CONFIG_TARGET_MT7981) += clk-mt7981.o -+obj-$(CONFIG_TARGET_MT7988) += clk-mt7988.o - obj-$(CONFIG_TARGET_MT8183) += clk-mt8183.o - obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.o - obj-$(CONFIG_TARGET_MT8518) += clk-mt8518.o ---- /dev/null -+++ b/drivers/clk/mediatek/clk-mt7988.c -@@ -0,0 +1,1123 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * MediaTek clock driver for MT7988 SoC -+ * -+ * Copyright (C) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "clk-mtk.h" -+ -+#define MT7988_CLK_PDN 0x250 -+#define MT7988_CLK_PDN_EN_WRITE BIT(31) -+ -+#define MT7988_ETHDMA_RST_CTRL_OFS 0x34 -+#define MT7988_ETHWARP_RST_CTRL_OFS 0x8 -+ -+#define XTAL_FACTOR(_id, _name, _parent, _mult, _div) \ -+ FACTOR(_id, _parent, _mult, _div, CLK_PARENT_XTAL) -+ -+#define PLL_FACTOR(_id, _name, _parent, _mult, _div) \ -+ FACTOR(_id, _parent, _mult, _div, CLK_PARENT_APMIXED) -+ -+#define TOP_FACTOR(_id, _name, _parent, _mult, _div) \ -+ FACTOR(_id, _parent, _mult, _div, CLK_PARENT_TOPCKGEN) -+ -+#define INFRA_FACTOR(_id, _name, _parent, _mult, _div) \ -+ FACTOR(_id, _parent, _mult, _div, CLK_PARENT_INFRASYS) -+ -+/* FIXED PLLS */ -+static const struct mtk_fixed_clk apmixedsys_mtk_plls[] = { -+ FIXED_CLK(CK_APMIXED_NETSYSPLL, CLK_XTAL, 850000000), -+ FIXED_CLK(CK_APMIXED_MPLL, CLK_XTAL, 416000000), -+ FIXED_CLK(CK_APMIXED_MMPLL, CLK_XTAL, 720000000), -+ FIXED_CLK(CK_APMIXED_APLL2, CLK_XTAL, 196608000), -+ FIXED_CLK(CK_APMIXED_NET1PLL, CLK_XTAL, 2500000000), -+ FIXED_CLK(CK_APMIXED_NET2PLL, CLK_XTAL, 800000000), -+ FIXED_CLK(CK_APMIXED_WEDMCUPLL, CLK_XTAL, 208000000), -+ FIXED_CLK(CK_APMIXED_SGMPLL, CLK_XTAL, 325000000), -+ FIXED_CLK(CK_APMIXED_ARM_B, CLK_XTAL, 1500000000), -+ FIXED_CLK(CK_APMIXED_CCIPLL2_B, CLK_XTAL, 960000000), -+ FIXED_CLK(CK_APMIXED_USXGMIIPLL, CLK_XTAL, 644533000), -+ FIXED_CLK(CK_APMIXED_MSDCPLL, CLK_XTAL, 400000000), -+}; -+ -+/* TOPCKGEN FIXED DIV */ -+static const struct mtk_fixed_factor topckgen_mtk_fixed_factors[] = { -+ XTAL_FACTOR(CK_TOP_CB_CKSQ_40M, "cb_cksq_40m", CLK_XTAL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_M_416M, "cb_m_416m", CK_APMIXED_MPLL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_M_D2, "cb_m_d2", CK_APMIXED_MPLL, 1, 2), -+ PLL_FACTOR(CK_TOP_M_D3_D2, "m_d3_d2", CK_APMIXED_MPLL, 1, 2), -+ PLL_FACTOR(CK_TOP_CB_M_D4, "cb_m_d4", CK_APMIXED_MPLL, 1, 4), -+ PLL_FACTOR(CK_TOP_CB_M_D8, "cb_m_d8", CK_APMIXED_MPLL, 1, 8), -+ PLL_FACTOR(CK_TOP_M_D8_D2, "m_d8_d2", CK_APMIXED_MPLL, 1, 16), -+ PLL_FACTOR(CK_TOP_CB_MM_720M, "cb_mm_720m", CK_APMIXED_MMPLL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_MM_D2, "cb_mm_d2", CK_APMIXED_MMPLL, 1, 2), -+ PLL_FACTOR(CK_TOP_CB_MM_D3_D5, "cb_mm_d3_d5", CK_APMIXED_MMPLL, 1, 15), -+ PLL_FACTOR(CK_TOP_CB_MM_D4, "cb_mm_d4", CK_APMIXED_MMPLL, 1, 4), -+ PLL_FACTOR(CK_TOP_MM_D6_D2, "mm_d6_d2", CK_APMIXED_MMPLL, 1, 12), -+ PLL_FACTOR(CK_TOP_CB_MM_D8, "cb_mm_d8", CK_APMIXED_MMPLL, 1, 8), -+ PLL_FACTOR(CK_TOP_CB_APLL2_196M, "cb_apll2_196m", CK_APMIXED_APLL2, 1, -+ 1), -+ PLL_FACTOR(CK_TOP_CB_APLL2_D4, "cb_apll2_d4", CK_APMIXED_APLL2, 1, 4), -+ PLL_FACTOR(CK_TOP_CB_NET1_D4, "cb_net1_d4", CK_APMIXED_NET1PLL, 1, 4), -+ PLL_FACTOR(CK_TOP_CB_NET1_D5, "cb_net1_d5", CK_APMIXED_NET1PLL, 1, 5), -+ PLL_FACTOR(CK_TOP_NET1_D5_D2, "net1_d5_d2", CK_APMIXED_NET1PLL, 1, 10), -+ PLL_FACTOR(CK_TOP_NET1_D5_D4, "net1_d5_d4", CK_APMIXED_NET1PLL, 1, 20), -+ PLL_FACTOR(CK_TOP_CB_NET1_D8, "cb_net1_d8", CK_APMIXED_NET1PLL, 1, 8), -+ PLL_FACTOR(CK_TOP_NET1_D8_D2, "net1_d8_d2", CK_APMIXED_NET1PLL, 1, 16), -+ PLL_FACTOR(CK_TOP_NET1_D8_D4, "net1_d8_d4", CK_APMIXED_NET1PLL, 1, 32), -+ PLL_FACTOR(CK_TOP_NET1_D8_D8, "net1_d8_d8", CK_APMIXED_NET1PLL, 1, 64), -+ PLL_FACTOR(CK_TOP_NET1_D8_D16, "net1_d8_d16", CK_APMIXED_NET1PLL, 1, -+ 128), -+ PLL_FACTOR(CK_TOP_CB_NET2_800M, "cb_net2_800m", CK_APMIXED_NET2PLL, 1, -+ 1), -+ PLL_FACTOR(CK_TOP_CB_NET2_D2, "cb_net2_d2", CK_APMIXED_NET2PLL, 1, 2), -+ PLL_FACTOR(CK_TOP_CB_NET2_D4, "cb_net2_d4", CK_APMIXED_NET2PLL, 1, 4), -+ PLL_FACTOR(CK_TOP_NET2_D4_D4, "net2_d4_d4", CK_APMIXED_NET2PLL, 1, 16), -+ PLL_FACTOR(CK_TOP_NET2_D4_D8, "net2_d4_d8", CK_APMIXED_NET2PLL, 1, 32), -+ PLL_FACTOR(CK_TOP_CB_NET2_D6, "cb_net2_d6", CK_APMIXED_NET2PLL, 1, 6), -+ PLL_FACTOR(CK_TOP_CB_NET2_D8, "cb_net2_d8", CK_APMIXED_NET2PLL, 1, 8), -+ PLL_FACTOR(CK_TOP_CB_WEDMCU_208M, "cb_wedmcu_208m", -+ CK_APMIXED_WEDMCUPLL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_SGM_325M, "cb_sgm_325m", CK_APMIXED_SGMPLL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_NETSYS_850M, "cb_netsys_850m", -+ CK_APMIXED_NETSYSPLL, 1, 1), -+ PLL_FACTOR(CK_TOP_CB_MSDC_400M, "cb_msdc_400m", CK_APMIXED_MSDCPLL, 1, -+ 1), -+ TOP_FACTOR(CK_TOP_CKSQ_40M_D2, "cksq_40m_d2", CK_TOP_CB_CKSQ_40M, 1, 2), -+ TOP_FACTOR(CK_TOP_CB_RTC_32K, "cb_rtc_32k", CK_TOP_CB_CKSQ_40M, 1, -+ 1250), -+ TOP_FACTOR(CK_TOP_CB_RTC_32P7K, "cb_rtc_32p7k", CK_TOP_CB_CKSQ_40M, 1, -+ 1220), -+ TOP_FACTOR(CK_TOP_INFRA_F32K, "csw_infra_f32k", CK_TOP_CB_RTC_32P7K, 1, -+ 1), -+ XTAL_FACTOR(CK_TOP_CKSQ_SRC, "cksq_src", CLK_XTAL, 1, 1), -+ TOP_FACTOR(CK_TOP_NETSYS_2X, "netsys_2x", CK_TOP_NETSYS_2X_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_NETSYS_GSW, "netsys_gsw", CK_TOP_NETSYS_GSW_SEL, 1, -+ 1), -+ TOP_FACTOR(CK_TOP_NETSYS_WED_MCU, "netsys_wed_mcu", -+ CK_TOP_NETSYS_MCU_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_EIP197, "eip197", CK_TOP_EIP197_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_EMMC_250M, "emmc_250m", CK_TOP_EMMC_250M_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_EMMC_400M, "emmc_400m", CK_TOP_EMMC_400M_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_SPI, "spi", CK_TOP_SPI_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_SPIM_MST, "spim_mst", CK_TOP_SPIM_MST_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_NFI1X, "nfi1x", CK_TOP_NFI1X_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_SPINFI_BCK, "spinfi_bck", CK_TOP_SPINFI_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_I2C_BCK, "i2c_bck", CK_TOP_I2C_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_USB_SYS, "usb_sys", CK_TOP_USB_SYS_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_USB_SYS_P1, "usb_sys_p1", CK_TOP_USB_SYS_P1_SEL, 1, -+ 1), -+ TOP_FACTOR(CK_TOP_USB_XHCI, "usb_xhci", CK_TOP_USB_XHCI_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_USB_XHCI_P1, "usb_xhci_p1", CK_TOP_USB_XHCI_P1_SEL, 1, -+ 1), -+ TOP_FACTOR(CK_TOP_USB_FRMCNT, "usb_frmcnt", CK_TOP_USB_FRMCNT_SEL, 1, -+ 1), -+ TOP_FACTOR(CK_TOP_USB_FRMCNT_P1, "usb_frmcnt_p1", -+ CK_TOP_USB_FRMCNT_P1_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_AUD, "aud", CK_TOP_AUD_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_A1SYS, "a1sys", CK_TOP_A1SYS_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_AUD_L, "aud_l", CK_TOP_AUD_L_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_A_TUNER, "a_tuner", CK_TOP_A_TUNER_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_SYSAXI, "sysaxi", CK_TOP_SYSAXI_SEL, 1, 1), -+ TOP_FACTOR(CK_TOP_INFRA_F26M, "csw_infra_f26m", CK_TOP_INFRA_F26M_SEL, -+ 1, 1), -+ TOP_FACTOR(CK_TOP_USB_REF, "usb_ref", CK_TOP_CKSQ_SRC, 1, 1), -+ TOP_FACTOR(CK_TOP_USB_CK_P1, "usb_ck_p1", CK_TOP_CKSQ_SRC, 1, 1), -+}; -+ -+/* TOPCKGEN MUX PARENTS */ -+static const int netsys_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NET2_D2, -+ CK_TOP_CB_MM_D2 }; -+ -+static const int netsys_500m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET1_D5, -+ CK_TOP_NET1_D5_D2 }; -+ -+static const int netsys_2x_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_800M, -+ CK_TOP_CB_MM_720M }; -+ -+static const int netsys_gsw_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NET1_D4, -+ CK_TOP_CB_NET1_D5 }; -+ -+static const int eth_gmii_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D4 }; -+ -+static const int netsys_mcu_parents[] = { -+ CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NET2_800M, CK_TOP_CB_MM_720M, -+ CK_TOP_CB_NET1_D4, CK_TOP_CB_NET1_D5, CK_TOP_CB_M_416M -+}; -+ -+static const int eip197_parents[] = { -+ CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NETSYS_850M, CK_TOP_CB_NET2_800M, -+ CK_TOP_CB_MM_720M, CK_TOP_CB_NET1_D4, CK_TOP_CB_NET1_D5 -+}; -+ -+static const int axi_infra_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_NET1_D8_D2 }; -+ -+static const int uart_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D8, -+ CK_TOP_M_D8_D2 }; -+ -+static const int emmc_250m_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D2, -+ CK_TOP_CB_MM_D4 }; -+ -+static const int emmc_400m_parents[] = { -+ CK_TOP_CB_CKSQ_40M, CK_TOP_CB_MSDC_400M, CK_TOP_CB_MM_D2, -+ CK_TOP_CB_M_D2, CK_TOP_CB_MM_D4, CK_TOP_NET1_D8_D2 -+}; -+ -+static const int spi_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D2, -+ CK_TOP_CB_MM_D4, CK_TOP_NET1_D8_D2, -+ CK_TOP_CB_NET2_D6, CK_TOP_NET1_D5_D4, -+ CK_TOP_CB_M_D4, CK_TOP_NET1_D8_D4 }; -+ -+static const int nfi1x_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_MM_D4, -+ CK_TOP_NET1_D8_D2, CK_TOP_CB_NET2_D6, -+ CK_TOP_CB_M_D4, CK_TOP_CB_MM_D8, -+ CK_TOP_NET1_D8_D4, CK_TOP_CB_M_D8 }; -+ -+static const int spinfi_parents[] = { CK_TOP_CKSQ_40M_D2, CK_TOP_CB_CKSQ_40M, -+ CK_TOP_NET1_D5_D4, CK_TOP_CB_M_D4, -+ CK_TOP_CB_MM_D8, CK_TOP_NET1_D8_D4, -+ CK_TOP_MM_D6_D2, CK_TOP_CB_M_D8 }; -+ -+static const int pwm_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D8_D2, -+ CK_TOP_NET1_D5_D4, CK_TOP_CB_M_D4, -+ CK_TOP_M_D8_D2, CK_TOP_CB_RTC_32K }; -+ -+static const int i2c_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D4, -+ CK_TOP_CB_M_D4, CK_TOP_NET1_D8_D4 }; -+ -+static const int pcie_mbist_250m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_NET1_D5_D2 }; -+ -+static const int pextp_tl_ck_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_D6, CK_TOP_CB_MM_D8, -+ CK_TOP_M_D8_D2, CK_TOP_CB_RTC_32K }; -+ -+static const int usb_frmcnt_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_MM_D3_D5 }; -+ -+static const int aud_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_APLL2_196M }; -+ -+static const int a1sys_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_APLL2_D4 }; -+ -+static const int aud_l_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_APLL2_196M, -+ CK_TOP_M_D8_D2 }; -+ -+static const int sspxtp_parents[] = { CK_TOP_CKSQ_40M_D2, CK_TOP_M_D8_D2 }; -+ -+static const int usxgmii_sbus_0_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_NET1_D8_D4 }; -+ -+static const int sgm_0_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_SGM_325M }; -+ -+static const int sysapb_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_M_D3_D2 }; -+ -+static const int eth_refck_50m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_NET2_D4_D4 }; -+ -+static const int eth_sys_200m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_D4 }; -+ -+static const int eth_xgmii_parents[] = { CK_TOP_CKSQ_40M_D2, CK_TOP_NET1_D8_D8, -+ CK_TOP_NET1_D8_D16 }; -+ -+static const int bus_tops_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NET1_D5, -+ CK_TOP_CB_NET2_D2 }; -+ -+static const int npu_tops_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_800M }; -+ -+static const int dramc_md32_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D2, -+ CK_TOP_CB_WEDMCU_208M }; -+ -+static const int da_xtp_glb_p0_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_D8 }; -+ -+static const int mcusys_backup_625m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET1_D4 }; -+ -+static const int macsec_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_SGM_325M, -+ CK_TOP_CB_NET1_D8 }; -+ -+static const int netsys_tops_400m_parents[] = { CK_TOP_CB_CKSQ_40M, -+ CK_TOP_CB_NET2_D2 }; -+ -+static const int eth_mii_parents[] = { CK_TOP_CKSQ_40M_D2, CK_TOP_NET2_D4_D8 }; -+ -+#define TOP_MUX(_id, _name, _parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ -+ _shift, _width, _gate, _upd_ofs, _upd) \ -+ { \ -+ .id = _id, .mux_reg = _mux_ofs, .mux_set_reg = _mux_set_ofs, \ -+ .mux_clr_reg = _mux_clr_ofs, .upd_reg = _upd_ofs, \ -+ .upd_shift = _upd, .mux_shift = _shift, \ -+ .mux_mask = BIT(_width) - 1, .gate_reg = _mux_ofs, \ -+ .gate_shift = _gate, .parent = _parents, \ -+ .num_parents = ARRAY_SIZE(_parents), \ -+ .flags = CLK_MUX_SETCLR_UPD, \ -+ } -+ -+/* TOPCKGEN MUX_GATE */ -+static const struct mtk_composite topckgen_mtk_muxes[] = { -+ TOP_MUX(CK_TOP_NETSYS_SEL, "netsys_sel", netsys_parents, 0x0, 0x4, 0x8, -+ 0, 2, 7, 0x1c0, 0), -+ TOP_MUX(CK_TOP_NETSYS_500M_SEL, "netsys_500m_sel", netsys_500m_parents, -+ 0x0, 0x4, 0x8, 8, 2, 15, 0x1c0, 1), -+ TOP_MUX(CK_TOP_NETSYS_2X_SEL, "netsys_2x_sel", netsys_2x_parents, 0x0, -+ 0x4, 0x8, 16, 2, 23, 0x1c0, 2), -+ TOP_MUX(CK_TOP_NETSYS_GSW_SEL, "netsys_gsw_sel", netsys_gsw_parents, -+ 0x0, 0x4, 0x8, 24, 2, 31, 0x1c0, 3), -+ TOP_MUX(CK_TOP_ETH_GMII_SEL, "eth_gmii_sel", eth_gmii_parents, 0x10, -+ 0x14, 0x18, 0, 1, 7, 0x1c0, 4), -+ TOP_MUX(CK_TOP_NETSYS_MCU_SEL, "netsys_mcu_sel", netsys_mcu_parents, -+ 0x10, 0x14, 0x18, 8, 3, 15, 0x1c0, 5), -+ TOP_MUX(CK_TOP_NETSYS_PAO_2X_SEL, "netsys_pao_2x_sel", -+ netsys_mcu_parents, 0x10, 0x14, 0x18, 16, 3, 23, 0x1c0, 6), -+ TOP_MUX(CK_TOP_EIP197_SEL, "eip197_sel", eip197_parents, 0x10, 0x14, -+ 0x18, 24, 3, 31, 0x1c0, 7), -+ TOP_MUX(CK_TOP_AXI_INFRA_SEL, "axi_infra_sel", axi_infra_parents, 0x20, -+ 0x24, 0x28, 0, 1, 7, 0x1c0, 8), -+ TOP_MUX(CK_TOP_UART_SEL, "uart_sel", uart_parents, 0x20, 0x24, 0x28, 8, -+ 2, 15, 0x1c0, 9), -+ TOP_MUX(CK_TOP_EMMC_250M_SEL, "emmc_250m_sel", emmc_250m_parents, 0x20, -+ 0x24, 0x28, 16, 2, 23, 0x1c0, 10), -+ TOP_MUX(CK_TOP_EMMC_400M_SEL, "emmc_400m_sel", emmc_400m_parents, 0x20, -+ 0x24, 0x28, 24, 3, 31, 0x1c0, 11), -+ TOP_MUX(CK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x30, 0x34, 0x38, 0, 3, -+ 7, 0x1c0, 12), -+ TOP_MUX(CK_TOP_SPIM_MST_SEL, "spim_mst_sel", spi_parents, 0x30, 0x34, -+ 0x38, 8, 3, 15, 0x1c0, 13), -+ TOP_MUX(CK_TOP_NFI1X_SEL, "nfi1x_sel", nfi1x_parents, 0x30, 0x34, 0x38, -+ 16, 3, 23, 0x1c0, 14), -+ TOP_MUX(CK_TOP_SPINFI_SEL, "spinfi_sel", spinfi_parents, 0x30, 0x34, -+ 0x38, 24, 3, 31, 0x1c0, 15), -+ TOP_MUX(CK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x40, 0x44, 0x48, 0, 3, -+ 7, 0x1c0, 16), -+ TOP_MUX(CK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x40, 0x44, 0x48, 8, 2, -+ 15, 0x1c0, 17), -+ TOP_MUX(CK_TOP_PCIE_MBIST_250M_SEL, "pcie_mbist_250m_sel", -+ pcie_mbist_250m_parents, 0x40, 0x44, 0x48, 16, 1, 23, 0x1c0, -+ 18), -+ TOP_MUX(CK_TOP_PEXTP_TL_SEL, "pextp_tl_ck_sel", pextp_tl_ck_parents, -+ 0x40, 0x44, 0x48, 24, 3, 31, 0x1c0, 19), -+ TOP_MUX(CK_TOP_PEXTP_TL_P1_SEL, "pextp_tl_ck_p1_sel", -+ pextp_tl_ck_parents, 0x50, 0x54, 0x58, 0, 3, 7, 0x1c0, 20), -+ TOP_MUX(CK_TOP_PEXTP_TL_P2_SEL, "pextp_tl_ck_p2_sel", -+ pextp_tl_ck_parents, 0x50, 0x54, 0x58, 8, 3, 15, 0x1c0, 21), -+ TOP_MUX(CK_TOP_PEXTP_TL_P3_SEL, "pextp_tl_ck_p3_sel", -+ pextp_tl_ck_parents, 0x50, 0x54, 0x58, 16, 3, 23, 0x1c0, 22), -+ TOP_MUX(CK_TOP_USB_SYS_SEL, "usb_sys_sel", eth_gmii_parents, 0x50, 0x54, -+ 0x58, 24, 1, 31, 0x1c0, 23), -+ TOP_MUX(CK_TOP_USB_SYS_P1_SEL, "usb_sys_p1_sel", eth_gmii_parents, 0x60, -+ 0x64, 0x68, 0, 1, 7, 0x1c0, 24), -+ TOP_MUX(CK_TOP_USB_XHCI_SEL, "usb_xhci_sel", eth_gmii_parents, 0x60, -+ 0x64, 0x68, 8, 1, 15, 0x1c0, 25), -+ TOP_MUX(CK_TOP_USB_XHCI_P1_SEL, "usb_xhci_p1_sel", eth_gmii_parents, -+ 0x60, 0x64, 0x68, 16, 1, 23, 0x1c0, 26), -+ TOP_MUX(CK_TOP_USB_FRMCNT_SEL, "usb_frmcnt_sel", usb_frmcnt_parents, -+ 0x60, 0x64, 0x68, 24, 1, 31, 0x1c0, 27), -+ TOP_MUX(CK_TOP_USB_FRMCNT_P1_SEL, "usb_frmcnt_p1_sel", -+ usb_frmcnt_parents, 0x70, 0x74, 0x78, 0, 1, 7, 0x1c0, 28), -+ TOP_MUX(CK_TOP_AUD_SEL, "aud_sel", aud_parents, 0x70, 0x74, 0x78, 8, 1, -+ 15, 0x1c0, 29), -+ TOP_MUX(CK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents, 0x70, 0x74, 0x78, -+ 16, 1, 23, 0x1c0, 30), -+ TOP_MUX(CK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents, 0x70, 0x74, 0x78, -+ 24, 2, 31, 0x1c4, 0), -+ TOP_MUX(CK_TOP_A_TUNER_SEL, "a_tuner_sel", a1sys_parents, 0x80, 0x84, -+ 0x88, 0, 1, 7, 0x1c4, 1), -+ TOP_MUX(CK_TOP_SSPXTP_SEL, "sspxtp_sel", sspxtp_parents, 0x80, 0x84, -+ 0x88, 8, 1, 15, 0x1c4, 2), -+ TOP_MUX(CK_TOP_USB_PHY_SEL, "usb_phy_sel", sspxtp_parents, 0x80, 0x84, -+ 0x88, 16, 1, 23, 0x1c4, 3), -+ TOP_MUX(CK_TOP_USXGMII_SBUS_0_SEL, "usxgmii_sbus_0_sel", -+ usxgmii_sbus_0_parents, 0x80, 0x84, 0x88, 24, 1, 31, 0x1c4, 4), -+ TOP_MUX(CK_TOP_USXGMII_SBUS_1_SEL, "usxgmii_sbus_1_sel", -+ usxgmii_sbus_0_parents, 0x90, 0x94, 0x98, 0, 1, 7, 0x1c4, 5), -+ TOP_MUX(CK_TOP_SGM_0_SEL, "sgm_0_sel", sgm_0_parents, 0x90, 0x94, 0x98, -+ 8, 1, 15, 0x1c4, 6), -+ TOP_MUX(CK_TOP_SGM_SBUS_0_SEL, "sgm_sbus_0_sel", usxgmii_sbus_0_parents, -+ 0x90, 0x94, 0x98, 16, 1, 23, 0x1c4, 7), -+ TOP_MUX(CK_TOP_SGM_1_SEL, "sgm_1_sel", sgm_0_parents, 0x90, 0x94, 0x98, -+ 24, 1, 31, 0x1c4, 8), -+ TOP_MUX(CK_TOP_SGM_SBUS_1_SEL, "sgm_sbus_1_sel", usxgmii_sbus_0_parents, -+ 0xa0, 0xa4, 0xa8, 0, 1, 7, 0x1c4, 9), -+ TOP_MUX(CK_TOP_XFI_PHY_0_XTAL_SEL, "xfi_phy_0_xtal_sel", sspxtp_parents, -+ 0xa0, 0xa4, 0xa8, 8, 1, 15, 0x1c4, 10), -+ TOP_MUX(CK_TOP_XFI_PHY_1_XTAL_SEL, "xfi_phy_1_xtal_sel", sspxtp_parents, -+ 0xa0, 0xa4, 0xa8, 16, 1, 23, 0x1c4, 11), -+ TOP_MUX(CK_TOP_SYSAXI_SEL, "sysaxi_sel", axi_infra_parents, 0xa0, 0xa4, -+ 0xa8, 24, 1, 31, 0x1c4, 12), -+ TOP_MUX(CK_TOP_SYSAPB_SEL, "sysapb_sel", sysapb_parents, 0xb0, 0xb4, -+ 0xb8, 0, 1, 7, 0x1c4, 13), -+ TOP_MUX(CK_TOP_ETH_REFCK_50M_SEL, "eth_refck_50m_sel", -+ eth_refck_50m_parents, 0xb0, 0xb4, 0xb8, 8, 1, 15, 0x1c4, 14), -+ TOP_MUX(CK_TOP_ETH_SYS_200M_SEL, "eth_sys_200m_sel", -+ eth_sys_200m_parents, 0xb0, 0xb4, 0xb8, 16, 1, 23, 0x1c4, 15), -+ TOP_MUX(CK_TOP_ETH_SYS_SEL, "eth_sys_sel", pcie_mbist_250m_parents, -+ 0xb0, 0xb4, 0xb8, 24, 1, 31, 0x1c4, 16), -+ TOP_MUX(CK_TOP_ETH_XGMII_SEL, "eth_xgmii_sel", eth_xgmii_parents, 0xc0, -+ 0xc4, 0xc8, 0, 2, 7, 0x1c4, 17), -+ TOP_MUX(CK_TOP_BUS_TOPS_SEL, "bus_tops_sel", bus_tops_parents, 0xc0, -+ 0xc4, 0xc8, 8, 2, 15, 0x1c4, 18), -+ TOP_MUX(CK_TOP_NPU_TOPS_SEL, "npu_tops_sel", npu_tops_parents, 0xc0, -+ 0xc4, 0xc8, 16, 1, 23, 0x1c4, 19), -+ TOP_MUX(CK_TOP_DRAMC_SEL, "dramc_sel", sspxtp_parents, 0xc0, 0xc4, 0xc8, -+ 24, 1, 31, 0x1c4, 20), -+ TOP_MUX(CK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel", dramc_md32_parents, -+ 0xd0, 0xd4, 0xd8, 0, 2, 7, 0x1c4, 21), -+ TOP_MUX(CK_TOP_INFRA_F26M_SEL, "csw_infra_f26m_sel", sspxtp_parents, -+ 0xd0, 0xd4, 0xd8, 8, 1, 15, 0x1c4, 22), -+ TOP_MUX(CK_TOP_PEXTP_P0_SEL, "pextp_p0_sel", sspxtp_parents, 0xd0, 0xd4, -+ 0xd8, 16, 1, 23, 0x1c4, 23), -+ TOP_MUX(CK_TOP_PEXTP_P1_SEL, "pextp_p1_sel", sspxtp_parents, 0xd0, 0xd4, -+ 0xd8, 24, 1, 31, 0x1c4, 24), -+ TOP_MUX(CK_TOP_PEXTP_P2_SEL, "pextp_p2_sel", sspxtp_parents, 0xe0, 0xe4, -+ 0xe8, 0, 1, 7, 0x1c4, 25), -+ TOP_MUX(CK_TOP_PEXTP_P3_SEL, "pextp_p3_sel", sspxtp_parents, 0xe0, 0xe4, -+ 0xe8, 8, 1, 15, 0x1c4, 26), -+ TOP_MUX(CK_TOP_DA_XTP_GLB_P0_SEL, "da_xtp_glb_p0_sel", -+ da_xtp_glb_p0_parents, 0xe0, 0xe4, 0xe8, 16, 1, 23, 0x1c4, 27), -+ TOP_MUX(CK_TOP_DA_XTP_GLB_P1_SEL, "da_xtp_glb_p1_sel", -+ da_xtp_glb_p0_parents, 0xe0, 0xe4, 0xe8, 24, 1, 31, 0x1c4, 28), -+ TOP_MUX(CK_TOP_DA_XTP_GLB_P2_SEL, "da_xtp_glb_p2_sel", -+ da_xtp_glb_p0_parents, 0xf0, 0xf4, 0xf8, 0, 1, 7, 0x1c4, 29), -+ TOP_MUX(CK_TOP_DA_XTP_GLB_P3_SEL, "da_xtp_glb_p3_sel", -+ da_xtp_glb_p0_parents, 0xf0, 0xf4, 0xf8, 8, 1, 15, 0x1c4, 30), -+ TOP_MUX(CK_TOP_CKM_SEL, "ckm_sel", sspxtp_parents, 0xf0, 0xf4, 0xf8, 16, -+ 1, 23, 0x1c8, 0), -+ TOP_MUX(CK_TOP_DA_SELM_XTAL_SEL, "da_selm_xtal_sel", sspxtp_parents, -+ 0xf0, 0xf4, 0xf8, 24, 1, 31, 0x1c8, 1), -+ TOP_MUX(CK_TOP_PEXTP_SEL, "pextp_sel", sspxtp_parents, 0x100, 0x104, -+ 0x108, 0, 1, 7, 0x1c8, 2), -+ TOP_MUX(CK_TOP_TOPS_P2_26M_SEL, "tops_p2_26m_sel", sspxtp_parents, -+ 0x100, 0x104, 0x108, 8, 1, 15, 0x1c8, 3), -+ TOP_MUX(CK_TOP_MCUSYS_BACKUP_625M_SEL, "mcusys_backup_625m_sel", -+ mcusys_backup_625m_parents, 0x100, 0x104, 0x108, 16, 1, 23, -+ 0x1c8, 4), -+ TOP_MUX(CK_TOP_NETSYS_SYNC_250M_SEL, "netsys_sync_250m_sel", -+ pcie_mbist_250m_parents, 0x100, 0x104, 0x108, 24, 1, 31, 0x1c8, -+ 5), -+ TOP_MUX(CK_TOP_MACSEC_SEL, "macsec_sel", macsec_parents, 0x110, 0x114, -+ 0x118, 0, 2, 7, 0x1c8, 6), -+ TOP_MUX(CK_TOP_NETSYS_TOPS_400M_SEL, "netsys_tops_400m_sel", -+ netsys_tops_400m_parents, 0x110, 0x114, 0x118, 8, 1, 15, 0x1c8, -+ 7), -+ TOP_MUX(CK_TOP_NETSYS_PPEFB_250M_SEL, "netsys_ppefb_250m_sel", -+ pcie_mbist_250m_parents, 0x110, 0x114, 0x118, 16, 1, 23, 0x1c8, -+ 8), -+ TOP_MUX(CK_TOP_NETSYS_WARP_SEL, "netsys_warp_sel", netsys_parents, -+ 0x110, 0x114, 0x118, 24, 2, 31, 0x1c8, 9), -+ TOP_MUX(CK_TOP_ETH_MII_SEL, "eth_mii_sel", eth_mii_parents, 0x120, -+ 0x124, 0x128, 0, 1, 7, 0x1c8, 10), -+ TOP_MUX(CK_TOP_CK_NPU_SEL_CM_TOPS_SEL, "ck_npu_sel_cm_tops_sel", -+ netsys_2x_parents, 0x120, 0x124, 0x128, 8, 2, 15, 0x1c8, 11), -+}; -+ -+/* INFRA FIXED DIV */ -+static const struct mtk_fixed_factor infracfg_mtk_fixed_factor[] = { -+ TOP_FACTOR(CK_INFRA_CK_F26M, "infra_ck_f26m", CK_TOP_INFRA_F26M_SEL, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_PWM_O, "infra_pwm_o", CK_TOP_PWM_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_PCIE_OCC_P0, "infra_pcie_ck_occ_p0", -+ CK_TOP_PEXTP_TL_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_PCIE_OCC_P1, "infra_pcie_ck_occ_p1", -+ CK_TOP_PEXTP_TL_P1_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_PCIE_OCC_P2, "infra_pcie_ck_occ_p2", -+ CK_TOP_PEXTP_TL_P2_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_PCIE_OCC_P3, "infra_pcie_ck_occ_p3", -+ CK_TOP_PEXTP_TL_P3_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_133M_HCK, "infra_133m_hck", CK_TOP_SYSAXI, 1, 1), -+ INFRA_FACTOR(CK_INFRA_133M_PHCK, "infra_133m_phck", CK_INFRA_133M_HCK, -+ 1, 1), -+ INFRA_FACTOR(CK_INFRA_66M_PHCK, "infra_66m_phck", CK_INFRA_133M_HCK, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_FAUD_L_O, "infra_faud_l_o", CK_TOP_AUD_L, 1, 1), -+ TOP_FACTOR(CK_INFRA_FAUD_AUD_O, "infra_faud_aud_o", CK_TOP_A1SYS, 1, 1), -+ TOP_FACTOR(CK_INFRA_FAUD_EG2_O, "infra_faud_eg2_o", CK_TOP_A_TUNER, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_I2C_O, "infra_i2c_o", CK_TOP_I2C_BCK, 1, 1), -+ TOP_FACTOR(CK_INFRA_UART_O0, "infra_uart_o0", CK_TOP_UART_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_UART_O1, "infra_uart_o1", CK_TOP_UART_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_UART_O2, "infra_uart_o2", CK_TOP_UART_SEL, 1, 1), -+ TOP_FACTOR(CK_INFRA_NFI_O, "infra_nfi_o", CK_TOP_NFI1X, 1, 1), -+ TOP_FACTOR(CK_INFRA_SPINFI_O, "infra_spinfi_o", CK_TOP_SPINFI_BCK, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_SPI0_O, "infra_spi0_o", CK_TOP_SPI, 1, 1), -+ TOP_FACTOR(CK_INFRA_SPI1_O, "infra_spi1_o", CK_TOP_SPIM_MST, 1, 1), -+ INFRA_FACTOR(CK_INFRA_LB_MUX_FRTC, "infra_lb_mux_frtc", CK_INFRA_FRTC, -+ 1, 1), -+ TOP_FACTOR(CK_INFRA_FRTC, "infra_frtc", CK_TOP_CB_RTC_32K, 1, 1), -+ TOP_FACTOR(CK_INFRA_FMSDC400_O, "infra_fmsdc400_o", CK_TOP_EMMC_400M, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_FMSDC2_HCK_OCC, "infra_fmsdc2_hck_occ", -+ CK_TOP_EMMC_250M, 1, 1), -+ TOP_FACTOR(CK_INFRA_PERI_133M, "infra_peri_133m", CK_TOP_SYSAXI, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_O, "infra_usb_o", CK_TOP_USB_REF, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_O_P1, "infra_usb_o_p1", CK_TOP_USB_CK_P1, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_FRMCNT_O, "infra_usb_frmcnt_o", -+ CK_TOP_USB_FRMCNT, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_FRMCNT_O_P1, "infra_usb_frmcnt_o_p1", -+ CK_TOP_USB_FRMCNT_P1, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_XHCI_O, "infra_usb_xhci_o", CK_TOP_USB_XHCI, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_USB_XHCI_O_P1, "infra_usb_xhci_o_p1", -+ CK_TOP_USB_XHCI_P1, 1, 1), -+ XTAL_FACTOR(CK_INFRA_USB_PIPE_O, "infra_usb_pipe_o", CLK_XTAL, 1, 1), -+ XTAL_FACTOR(CK_INFRA_USB_PIPE_O_P1, "infra_usb_pipe_o_p1", CLK_XTAL, 1, -+ 1), -+ XTAL_FACTOR(CK_INFRA_USB_UTMI_O, "infra_usb_utmi_o", CLK_XTAL, 1, 1), -+ XTAL_FACTOR(CK_INFRA_USB_UTMI_O_P1, "infra_usb_utmi_o_p1", CLK_XTAL, 1, -+ 1), -+ XTAL_FACTOR(CK_INFRA_PCIE_PIPE_OCC_P0, "infra_pcie_pipe_ck_occ_p0", -+ CLK_XTAL, 1, 1), -+ XTAL_FACTOR(CK_INFRA_PCIE_PIPE_OCC_P1, "infra_pcie_pipe_ck_occ_p1", -+ CLK_XTAL, 1, 1), -+ XTAL_FACTOR(CK_INFRA_PCIE_PIPE_OCC_P2, "infra_pcie_pipe_ck_occ_p2", -+ CLK_XTAL, 1, 1), -+ XTAL_FACTOR(CK_INFRA_PCIE_PIPE_OCC_P3, "infra_pcie_pipe_ck_occ_p3", -+ CLK_XTAL, 1, 1), -+ TOP_FACTOR(CK_INFRA_F26M_O0, "infra_f26m_o0", CK_TOP_INFRA_F26M, 1, 1), -+ TOP_FACTOR(CK_INFRA_F26M_O1, "infra_f26m_o1", CK_TOP_INFRA_F26M, 1, 1), -+ TOP_FACTOR(CK_INFRA_133M_MCK, "infra_133m_mck", CK_TOP_SYSAXI, 1, 1), -+ TOP_FACTOR(CK_INFRA_66M_MCK, "infra_66m_mck", CK_TOP_SYSAXI, 1, 1), -+ TOP_FACTOR(CK_INFRA_PERI_66M_O, "infra_peri_66m_o", CK_TOP_SYSAXI, 1, -+ 1), -+ TOP_FACTOR(CK_INFRA_USB_SYS_O, "infra_usb_sys_o", CK_TOP_USB_SYS, 1, 1), -+ TOP_FACTOR(CK_INFRA_USB_SYS_O_P1, "infra_usb_sys_o_p1", -+ CK_TOP_USB_SYS_P1, 1, 1), -+}; -+ -+/* INFRASYS MUX PARENTS */ -+static const int infra_mux_uart0_parents[] = { CK_INFRA_CK_F26M, -+ CK_INFRA_UART_O0 }; -+ -+static const int infra_mux_uart1_parents[] = { CK_INFRA_CK_F26M, -+ CK_INFRA_UART_O1 }; -+ -+static const int infra_mux_uart2_parents[] = { CK_INFRA_CK_F26M, -+ CK_INFRA_UART_O2 }; -+ -+static const int infra_mux_spi0_parents[] = { CK_INFRA_I2C_O, CK_INFRA_SPI0_O }; -+ -+static const int infra_mux_spi1_parents[] = { CK_INFRA_I2C_O, CK_INFRA_SPI1_O }; -+ -+static const int infra_pwm_bck_parents[] = { CK_TOP_INFRA_F32K, -+ CK_INFRA_CK_F26M, CK_INFRA_66M_MCK, -+ CK_INFRA_PWM_O }; -+ -+static const int infra_pcie_gfmux_tl_ck_o_p0_parents[] = { -+ CK_TOP_INFRA_F32K, CK_INFRA_CK_F26M, CK_INFRA_CK_F26M, -+ CK_INFRA_PCIE_OCC_P0 -+}; -+ -+static const int infra_pcie_gfmux_tl_ck_o_p1_parents[] = { -+ CK_TOP_INFRA_F32K, CK_INFRA_CK_F26M, CK_INFRA_CK_F26M, -+ CK_INFRA_PCIE_OCC_P1 -+}; -+ -+static const int infra_pcie_gfmux_tl_ck_o_p2_parents[] = { -+ CK_TOP_INFRA_F32K, CK_INFRA_CK_F26M, CK_INFRA_CK_F26M, -+ CK_INFRA_PCIE_OCC_P2 -+}; -+ -+static const int infra_pcie_gfmux_tl_ck_o_p3_parents[] = { -+ CK_TOP_INFRA_F32K, CK_INFRA_CK_F26M, CK_INFRA_CK_F26M, -+ CK_INFRA_PCIE_OCC_P3 -+}; -+ -+#define INFRA_MUX(_id, _name, _parents, _reg, _shift, _width) \ -+ { \ -+ .id = _id, .mux_reg = _reg + 0x8, .mux_set_reg = _reg + 0x0, \ -+ .mux_clr_reg = _reg + 0x4, .mux_shift = _shift, \ -+ .mux_mask = BIT(_width) - 1, .parent = _parents, \ -+ .num_parents = ARRAY_SIZE(_parents), \ -+ .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_INFRASYS, \ -+ } -+ -+/* INFRA MUX */ -+static const struct mtk_composite infracfg_mtk_mux[] = { -+ INFRA_MUX(CK_INFRA_MUX_UART0_SEL, "infra_mux_uart0_sel", -+ infra_mux_uart0_parents, 0x10, 0, 1), -+ INFRA_MUX(CK_INFRA_MUX_UART1_SEL, "infra_mux_uart1_sel", -+ infra_mux_uart1_parents, 0x10, 1, 1), -+ INFRA_MUX(CK_INFRA_MUX_UART2_SEL, "infra_mux_uart2_sel", -+ infra_mux_uart2_parents, 0x10, 2, 1), -+ INFRA_MUX(CK_INFRA_MUX_SPI0_SEL, "infra_mux_spi0_sel", -+ infra_mux_spi0_parents, 0x10, 4, 1), -+ INFRA_MUX(CK_INFRA_MUX_SPI1_SEL, "infra_mux_spi1_sel", -+ infra_mux_spi1_parents, 0x10, 5, 1), -+ INFRA_MUX(CK_INFRA_MUX_SPI2_SEL, "infra_mux_spi2_sel", -+ infra_mux_spi0_parents, 0x10, 6, 1), -+ INFRA_MUX(CK_INFRA_PWM_SEL, "infra_pwm_sel", infra_pwm_bck_parents, -+ 0x10, 14, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK1_SEL, "infra_pwm_ck1_sel", -+ infra_pwm_bck_parents, 0x10, 16, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK2_SEL, "infra_pwm_ck2_sel", -+ infra_pwm_bck_parents, 0x10, 18, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK3_SEL, "infra_pwm_ck3_sel", -+ infra_pwm_bck_parents, 0x10, 20, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK4_SEL, "infra_pwm_ck4_sel", -+ infra_pwm_bck_parents, 0x10, 22, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK5_SEL, "infra_pwm_ck5_sel", -+ infra_pwm_bck_parents, 0x10, 24, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK6_SEL, "infra_pwm_ck6_sel", -+ infra_pwm_bck_parents, 0x10, 26, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK7_SEL, "infra_pwm_ck7_sel", -+ infra_pwm_bck_parents, 0x10, 28, 2), -+ INFRA_MUX(CK_INFRA_PWM_CK8_SEL, "infra_pwm_ck8_sel", -+ infra_pwm_bck_parents, 0x10, 30, 2), -+ INFRA_MUX(CK_INFRA_PCIE_GFMUX_TL_O_P0_SEL, -+ "infra_pcie_gfmux_tl_o_p0_sel", -+ infra_pcie_gfmux_tl_ck_o_p0_parents, 0x20, 0, 2), -+ INFRA_MUX(CK_INFRA_PCIE_GFMUX_TL_O_P1_SEL, -+ "infra_pcie_gfmux_tl_o_p1_sel", -+ infra_pcie_gfmux_tl_ck_o_p1_parents, 0x20, 2, 2), -+ INFRA_MUX(CK_INFRA_PCIE_GFMUX_TL_O_P2_SEL, -+ "infra_pcie_gfmux_tl_o_p2_sel", -+ infra_pcie_gfmux_tl_ck_o_p2_parents, 0x20, 4, 2), -+ INFRA_MUX(CK_INFRA_PCIE_GFMUX_TL_O_P3_SEL, -+ "infra_pcie_gfmux_tl_o_p3_sel", -+ infra_pcie_gfmux_tl_ck_o_p3_parents, 0x20, 6, 2), -+}; -+ -+static const struct mtk_gate_regs infra_0_cg_regs = { -+ .set_ofs = 0x10, -+ .clr_ofs = 0x14, -+ .sta_ofs = 0x18, -+}; -+ -+static const struct mtk_gate_regs infra_1_cg_regs = { -+ .set_ofs = 0x40, -+ .clr_ofs = 0x44, -+ .sta_ofs = 0x48, -+}; -+ -+static const struct mtk_gate_regs infra_2_cg_regs = { -+ .set_ofs = 0x50, -+ .clr_ofs = 0x54, -+ .sta_ofs = 0x58, -+}; -+ -+static const struct mtk_gate_regs infra_3_cg_regs = { -+ .set_ofs = 0x60, -+ .clr_ofs = 0x64, -+ .sta_ofs = 0x68, -+}; -+ -+#define GATE_INFRA0(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &infra_0_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \ -+ } -+ -+#define GATE_INFRA1(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &infra_1_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \ -+ } -+ -+#define GATE_INFRA2(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &infra_2_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \ -+ } -+ -+#define GATE_INFRA3(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &infra_3_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \ -+ } -+ -+/* INFRA GATE */ -+static const struct mtk_gate infracfg_mtk_gates[] = { -+ GATE_INFRA1(CK_INFRA_66M_GPT_BCK, "infra_hf_66m_gpt_bck", -+ CK_INFRA_66M_MCK, 0), -+ GATE_INFRA1(CK_INFRA_66M_PWM_HCK, "infra_hf_66m_pwm_hck", -+ CK_INFRA_66M_MCK, 1), -+ GATE_INFRA1(CK_INFRA_66M_PWM_BCK, "infra_hf_66m_pwm_bck", -+ CK_INFRA_PWM_SEL, 2), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK1, "infra_hf_66m_pwm_ck1", -+ CK_INFRA_PWM_CK1_SEL, 3), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK2, "infra_hf_66m_pwm_ck2", -+ CK_INFRA_PWM_CK2_SEL, 4), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK3, "infra_hf_66m_pwm_ck3", -+ CK_INFRA_PWM_CK3_SEL, 5), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK4, "infra_hf_66m_pwm_ck4", -+ CK_INFRA_PWM_CK4_SEL, 6), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK5, "infra_hf_66m_pwm_ck5", -+ CK_INFRA_PWM_CK5_SEL, 7), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK6, "infra_hf_66m_pwm_ck6", -+ CK_INFRA_PWM_CK6_SEL, 8), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK7, "infra_hf_66m_pwm_ck7", -+ CK_INFRA_PWM_CK7_SEL, 9), -+ GATE_INFRA1(CK_INFRA_66M_PWM_CK8, "infra_hf_66m_pwm_ck8", -+ CK_INFRA_PWM_CK8_SEL, 10), -+ GATE_INFRA1(CK_INFRA_133M_CQDMA_BCK, "infra_hf_133m_cqdma_bck", -+ CK_INFRA_133M_MCK, 12), -+ GATE_INFRA1(CK_INFRA_66M_AUD_SLV_BCK, "infra_66m_aud_slv_bck", -+ CK_INFRA_66M_PHCK, 13), -+ GATE_INFRA1(CK_INFRA_AUD_26M, "infra_f_faud_26m", CK_INFRA_CK_F26M, 14), -+ GATE_INFRA1(CK_INFRA_AUD_L, "infra_f_faud_l", CK_INFRA_FAUD_L_O, 15), -+ GATE_INFRA1(CK_INFRA_AUD_AUD, "infra_f_aud_aud", CK_INFRA_FAUD_AUD_O, -+ 16), -+ GATE_INFRA1(CK_INFRA_AUD_EG2, "infra_f_faud_eg2", CK_INFRA_FAUD_EG2_O, -+ 18), -+ GATE_INFRA1(CK_INFRA_DRAMC_F26M, "infra_dramc_f26m", CK_INFRA_CK_F26M, -+ 19), -+ GATE_INFRA1(CK_INFRA_133M_DBG_ACKM, "infra_hf_133m_dbg_ackm", -+ CK_INFRA_133M_MCK, 20), -+ GATE_INFRA1(CK_INFRA_66M_AP_DMA_BCK, "infra_66m_ap_dma_bck", -+ CK_INFRA_66M_MCK, 21), -+ GATE_INFRA1(CK_INFRA_66M_SEJ_BCK, "infra_hf_66m_sej_bck", -+ CK_INFRA_66M_MCK, 29), -+ GATE_INFRA1(CK_INFRA_PRE_CK_SEJ_F13M, "infra_pre_ck_sej_f13m", -+ CK_INFRA_CK_F26M, 30), -+ GATE_INFRA1(CK_INFRA_66M_TRNG, "infra_hf_66m_trng", CK_INFRA_PERI_66M_O, -+ 31), -+ GATE_INFRA2(CK_INFRA_26M_THERM_SYSTEM, "infra_hf_26m_therm_system", -+ CK_INFRA_CK_F26M, 0), -+ GATE_INFRA2(CK_INFRA_I2C_BCK, "infra_i2c_bck", CK_INFRA_I2C_O, 1), -+ GATE_INFRA2(CK_INFRA_66M_UART0_PCK, "infra_hf_66m_uart0_pck", -+ CK_INFRA_66M_MCK, 3), -+ GATE_INFRA2(CK_INFRA_66M_UART1_PCK, "infra_hf_66m_uart1_pck", -+ CK_INFRA_66M_MCK, 4), -+ GATE_INFRA2(CK_INFRA_66M_UART2_PCK, "infra_hf_66m_uart2_pck", -+ CK_INFRA_66M_MCK, 5), -+ GATE_INFRA2(CK_INFRA_52M_UART0_CK, "infra_f_52m_uart0", -+ CK_INFRA_MUX_UART0_SEL, 3), -+ GATE_INFRA2(CK_INFRA_52M_UART1_CK, "infra_f_52m_uart1", -+ CK_INFRA_MUX_UART1_SEL, 4), -+ GATE_INFRA2(CK_INFRA_52M_UART2_CK, "infra_f_52m_uart2", -+ CK_INFRA_MUX_UART2_SEL, 5), -+ GATE_INFRA2(CK_INFRA_NFI, "infra_f_fnfi", CK_INFRA_NFI_O, 9), -+ GATE_INFRA2(CK_INFRA_SPINFI, "infra_f_fspinfi", CK_INFRA_SPINFI_O, 10), -+ GATE_INFRA2(CK_INFRA_66M_NFI_HCK, "infra_hf_66m_nfi_hck", -+ CK_INFRA_66M_MCK, 11), -+ GATE_INFRA2(CK_INFRA_104M_SPI0, "infra_hf_104m_spi0", -+ CK_INFRA_MUX_SPI0_SEL, 12), -+ GATE_INFRA2(CK_INFRA_104M_SPI1, "infra_hf_104m_spi1", -+ CK_INFRA_MUX_SPI1_SEL, 13), -+ GATE_INFRA2(CK_INFRA_104M_SPI2_BCK, "infra_hf_104m_spi2_bck", -+ CK_INFRA_MUX_SPI2_SEL, 14), -+ GATE_INFRA2(CK_INFRA_66M_SPI0_HCK, "infra_hf_66m_spi0_hck", -+ CK_INFRA_66M_MCK, 15), -+ GATE_INFRA2(CK_INFRA_66M_SPI1_HCK, "infra_hf_66m_spi1_hck", -+ CK_INFRA_66M_MCK, 16), -+ GATE_INFRA2(CK_INFRA_66M_SPI2_HCK, "infra_hf_66m_spi2_hck", -+ CK_INFRA_66M_MCK, 17), -+ GATE_INFRA2(CK_INFRA_66M_FLASHIF_AXI, "infra_hf_66m_flashif_axi", -+ CK_INFRA_66M_MCK, 18), -+ GATE_INFRA2(CK_INFRA_RTC, "infra_f_frtc", CK_INFRA_LB_MUX_FRTC, 19), -+ GATE_INFRA2(CK_INFRA_26M_ADC_BCK, "infra_f_26m_adc_bck", -+ CK_INFRA_F26M_O1, 20), -+ GATE_INFRA2(CK_INFRA_RC_ADC, "infra_f_frc_adc", CK_INFRA_26M_ADC_BCK, -+ 21), -+ GATE_INFRA2(CK_INFRA_MSDC400, "infra_f_fmsdc400", CK_INFRA_FMSDC400_O, -+ 22), -+ GATE_INFRA2(CK_INFRA_MSDC2_HCK, "infra_f_fmsdc2_hck", -+ CK_INFRA_FMSDC2_HCK_OCC, 23), -+ GATE_INFRA2(CK_INFRA_133M_MSDC_0_HCK, "infra_hf_133m_msdc_0_hck", -+ CK_INFRA_PERI_133M, 24), -+ GATE_INFRA2(CK_INFRA_66M_MSDC_0_HCK, "infra_66m_msdc_0_hck", -+ CK_INFRA_66M_PHCK, 25), -+ GATE_INFRA2(CK_INFRA_133M_CPUM_BCK, "infra_hf_133m_cpum_bck", -+ CK_INFRA_133M_MCK, 26), -+ GATE_INFRA2(CK_INFRA_BIST2FPC, "infra_hf_fbist2fpc", CK_INFRA_NFI_O, -+ 27), -+ GATE_INFRA2(CK_INFRA_I2C_X16W_MCK_CK_P1, "infra_hf_i2c_x16w_mck_ck_p1", -+ CK_INFRA_133M_MCK, 29), -+ GATE_INFRA2(CK_INFRA_I2C_X16W_PCK_CK_P1, "infra_hf_i2c_x16w_pck_ck_p1", -+ CK_INFRA_66M_PHCK, 31), -+ GATE_INFRA3(CK_INFRA_133M_USB_HCK, "infra_133m_usb_hck", -+ CK_INFRA_133M_PHCK, 0), -+ GATE_INFRA3(CK_INFRA_133M_USB_HCK_CK_P1, "infra_133m_usb_hck_ck_p1", -+ CK_INFRA_133M_PHCK, 1), -+ GATE_INFRA3(CK_INFRA_66M_USB_HCK, "infra_66m_usb_hck", -+ CK_INFRA_66M_PHCK, 2), -+ GATE_INFRA3(CK_INFRA_66M_USB_HCK_CK_P1, "infra_66m_usb_hck_ck_p1", -+ CK_INFRA_66M_PHCK, 3), -+ GATE_INFRA3(CK_INFRA_USB_SYS, "infra_usb_sys", CK_INFRA_USB_SYS_O, 4), -+ GATE_INFRA3(CK_INFRA_USB_SYS_CK_P1, "infra_usb_sys_ck_p1", -+ CK_INFRA_USB_SYS_O_P1, 5), -+ GATE_INFRA3(CK_INFRA_USB_REF, "infra_usb_ref", CK_INFRA_USB_O, 6), -+ GATE_INFRA3(CK_INFRA_USB_CK_P1, "infra_usb_ck_p1", CK_INFRA_USB_O_P1, -+ 7), -+ GATE_INFRA3(CK_INFRA_USB_FRMCNT, "infra_usb_frmcnt", -+ CK_INFRA_USB_FRMCNT_O, 8), -+ GATE_INFRA3(CK_INFRA_USB_FRMCNT_CK_P1, "infra_usb_frmcnt_ck_p1", -+ CK_INFRA_USB_FRMCNT_O_P1, 9), -+ GATE_INFRA3(CK_INFRA_USB_PIPE, "infra_usb_pipe", CK_INFRA_USB_PIPE_O, -+ 10), -+ GATE_INFRA3(CK_INFRA_USB_PIPE_CK_P1, "infra_usb_pipe_ck_p1", -+ CK_INFRA_USB_PIPE_O_P1, 11), -+ GATE_INFRA3(CK_INFRA_USB_UTMI, "infra_usb_utmi", CK_INFRA_USB_UTMI_O, -+ 12), -+ GATE_INFRA3(CK_INFRA_USB_UTMI_CK_P1, "infra_usb_utmi_ck_p1", -+ CK_INFRA_USB_UTMI_O_P1, 13), -+ GATE_INFRA3(CK_INFRA_USB_XHCI, "infra_usb_xhci", CK_INFRA_USB_XHCI_O, -+ 14), -+ GATE_INFRA3(CK_INFRA_USB_XHCI_CK_P1, "infra_usb_xhci_ck_p1", -+ CK_INFRA_USB_XHCI_O_P1, 15), -+ GATE_INFRA3(CK_INFRA_PCIE_GFMUX_TL_P0, "infra_pcie_gfmux_tl_ck_p0", -+ CK_INFRA_PCIE_GFMUX_TL_O_P0_SEL, 20), -+ GATE_INFRA3(CK_INFRA_PCIE_GFMUX_TL_P1, "infra_pcie_gfmux_tl_ck_p1", -+ CK_INFRA_PCIE_GFMUX_TL_O_P1_SEL, 21), -+ GATE_INFRA3(CK_INFRA_PCIE_GFMUX_TL_P2, "infra_pcie_gfmux_tl_ck_p2", -+ CK_INFRA_PCIE_GFMUX_TL_O_P2_SEL, 22), -+ GATE_INFRA3(CK_INFRA_PCIE_GFMUX_TL_P3, "infra_pcie_gfmux_tl_ck_p3", -+ CK_INFRA_PCIE_GFMUX_TL_O_P3_SEL, 23), -+ GATE_INFRA3(CK_INFRA_PCIE_PIPE_P0, "infra_pcie_pipe_ck_p0", -+ CK_INFRA_PCIE_PIPE_OCC_P0, 24), -+ GATE_INFRA3(CK_INFRA_PCIE_PIPE_P1, "infra_pcie_pipe_ck_p1", -+ CK_INFRA_PCIE_PIPE_OCC_P1, 25), -+ GATE_INFRA3(CK_INFRA_PCIE_PIPE_P2, "infra_pcie_pipe_ck_p2", -+ CK_INFRA_PCIE_PIPE_OCC_P2, 26), -+ GATE_INFRA3(CK_INFRA_PCIE_PIPE_P3, "infra_pcie_pipe_ck_p3", -+ CK_INFRA_PCIE_PIPE_OCC_P3, 27), -+ GATE_INFRA3(CK_INFRA_133M_PCIE_CK_P0, "infra_133m_pcie_ck_p0", -+ CK_INFRA_133M_PHCK, 28), -+ GATE_INFRA3(CK_INFRA_133M_PCIE_CK_P1, "infra_133m_pcie_ck_p1", -+ CK_INFRA_133M_PHCK, 29), -+ GATE_INFRA3(CK_INFRA_133M_PCIE_CK_P2, "infra_133m_pcie_ck_p2", -+ CK_INFRA_133M_PHCK, 30), -+ GATE_INFRA3(CK_INFRA_133M_PCIE_CK_P3, "infra_133m_pcie_ck_p3", -+ CK_INFRA_133M_PHCK, 31), -+ GATE_INFRA0(CK_INFRA_PCIE_PERI_26M_CK_P0, -+ "infra_pcie_peri_ck_26m_ck_p0", CK_INFRA_F26M_O0, 7), -+ GATE_INFRA0(CK_INFRA_PCIE_PERI_26M_CK_P1, -+ "infra_pcie_peri_ck_26m_ck_p1", CK_INFRA_F26M_O0, 8), -+ GATE_INFRA0(CK_INFRA_PCIE_PERI_26M_CK_P2, -+ "infra_pcie_peri_ck_26m_ck_p2", CK_INFRA_F26M_O0, 9), -+ GATE_INFRA0(CK_INFRA_PCIE_PERI_26M_CK_P3, -+ "infra_pcie_peri_ck_26m_ck_p3", CK_INFRA_F26M_O0, 10), -+}; -+ -+static const struct mtk_clk_tree mt7988_fixed_pll_clk_tree = { -+ .fdivs_offs = ARRAY_SIZE(apmixedsys_mtk_plls), -+ .fclks = apmixedsys_mtk_plls, -+ .xtal_rate = 40 * MHZ, -+}; -+ -+static const struct mtk_clk_tree mt7988_topckgen_clk_tree = { -+ .fdivs_offs = CK_TOP_CB_CKSQ_40M, -+ .muxes_offs = CK_TOP_NETSYS_SEL, -+ .fdivs = topckgen_mtk_fixed_factors, -+ .muxes = topckgen_mtk_muxes, -+ .flags = CLK_BYPASS_XTAL, -+ .xtal_rate = 40 * MHZ, -+}; -+ -+static const struct mtk_clk_tree mt7988_infracfg_clk_tree = { -+ .fdivs_offs = CK_INFRA_CK_F26M, -+ .muxes_offs = CK_INFRA_MUX_UART0_SEL, -+ .fdivs = infracfg_mtk_fixed_factor, -+ .muxes = infracfg_mtk_mux, -+ .flags = CLK_BYPASS_XTAL, -+ .xtal_rate = 40 * MHZ, -+}; -+ -+static const struct udevice_id mt7988_fixed_pll_compat[] = { -+ { .compatible = "mediatek,mt7988-fixed-plls" }, -+ {} -+}; -+ -+static const struct udevice_id mt7988_topckgen_compat[] = { -+ { .compatible = "mediatek,mt7988-topckgen" }, -+ {} -+}; -+ -+static int mt7988_fixed_pll_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_init(dev, &mt7988_fixed_pll_clk_tree); -+} -+ -+static int mt7988_topckgen_probe(struct udevice *dev) -+{ -+ struct mtk_clk_priv *priv = dev_get_priv(dev); -+ -+ priv->base = dev_read_addr_ptr(dev); -+ if (!priv->base) -+ return -ENOENT; -+ -+ writel(MT7988_CLK_PDN_EN_WRITE, priv->base + MT7988_CLK_PDN); -+ return mtk_common_clk_init(dev, &mt7988_topckgen_clk_tree); -+} -+ -+U_BOOT_DRIVER(mtk_clk_apmixedsys) = { -+ .name = "mt7988-clock-fixed-pll", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_fixed_pll_compat, -+ .probe = mt7988_fixed_pll_probe, -+ .priv_auto = sizeof(struct mtk_clk_priv), -+ .ops = &mtk_clk_topckgen_ops, -+ .flags = DM_FLAG_PRE_RELOC, -+}; -+ -+U_BOOT_DRIVER(mtk_clk_topckgen) = { -+ .name = "mt7988-clock-topckgen", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_topckgen_compat, -+ .probe = mt7988_topckgen_probe, -+ .priv_auto = sizeof(struct mtk_clk_priv), -+ .ops = &mtk_clk_topckgen_ops, -+ .flags = DM_FLAG_PRE_RELOC, -+}; -+ -+static const struct udevice_id mt7988_infracfg_compat[] = { -+ { .compatible = "mediatek,mt7988-infracfg" }, -+ {} -+}; -+ -+static const struct udevice_id mt7988_infracfg_ao_cgs_compat[] = { -+ { .compatible = "mediatek,mt7988-infracfg_ao_cgs" }, -+ {} -+}; -+ -+static int mt7988_infracfg_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_init(dev, &mt7988_infracfg_clk_tree); -+} -+ -+static int mt7988_infracfg_ao_cgs_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_gate_init(dev, &mt7988_infracfg_clk_tree, -+ infracfg_mtk_gates); -+} -+ -+U_BOOT_DRIVER(mtk_clk_infracfg) = { -+ .name = "mt7988-clock-infracfg", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_infracfg_compat, -+ .probe = mt7988_infracfg_probe, -+ .priv_auto = sizeof(struct mtk_clk_priv), -+ .ops = &mtk_clk_infrasys_ops, -+ .flags = DM_FLAG_PRE_RELOC, -+}; -+ -+U_BOOT_DRIVER(mtk_clk_infracfg_ao_cgs) = { -+ .name = "mt7988-clock-infracfg_ao_cgs", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_infracfg_ao_cgs_compat, -+ .probe = mt7988_infracfg_ao_cgs_probe, -+ .priv_auto = sizeof(struct mtk_cg_priv), -+ .ops = &mtk_clk_gate_ops, -+ .flags = DM_FLAG_PRE_RELOC, -+}; -+ -+/* ETHDMA */ -+ -+static const struct mtk_gate_regs ethdma_cg_regs = { -+ .set_ofs = 0x30, -+ .clr_ofs = 0x30, -+ .sta_ofs = 0x30, -+}; -+ -+#define GATE_ETHDMA(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = ðdma_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ -+ } -+ -+static const struct mtk_gate ethdma_mtk_gate[] = { -+ GATE_ETHDMA(CK_ETHDMA_FE_EN, "ethdma_fe_en", CK_TOP_NETSYS_2X, 6), -+}; -+ -+static int mt7988_ethdma_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, -+ ethdma_mtk_gate); -+} -+ -+static int mt7988_ethdma_bind(struct udevice *dev) -+{ -+ int ret = 0; -+ -+ if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { -+ ret = mediatek_reset_bind(dev, MT7988_ETHDMA_RST_CTRL_OFS, 1); -+ if (ret) -+ debug("Warning: failed to bind reset controller\n"); -+ } -+ -+ return ret; -+} -+ -+static const struct udevice_id mt7988_ethdma_compat[] = { -+ { -+ .compatible = "mediatek,mt7988-ethdma", -+ }, -+ {} -+}; -+ -+U_BOOT_DRIVER(mtk_clk_ethdma) = { -+ .name = "mt7988-clock-ethdma", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_ethdma_compat, -+ .probe = mt7988_ethdma_probe, -+ .bind = mt7988_ethdma_bind, -+ .priv_auto = sizeof(struct mtk_cg_priv), -+ .ops = &mtk_clk_gate_ops, -+}; -+ -+/* SGMIISYS_0 */ -+ -+static const struct mtk_gate_regs sgmii0_cg_regs = { -+ .set_ofs = 0xE4, -+ .clr_ofs = 0xE4, -+ .sta_ofs = 0xE4, -+}; -+ -+#define GATE_SGMII0(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &sgmii0_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ -+ } -+ -+static const struct mtk_gate sgmiisys_0_mtk_gate[] = { -+ /* connect to fake clock, so use CK_TOP_CB_CKSQ_40M as the clock parent */ -+ GATE_SGMII0(CK_SGM0_TX_EN, "sgm0_tx_en", CK_TOP_CB_CKSQ_40M, 2), -+ /* connect to fake clock, so use CK_TOP_CB_CKSQ_40M as the clock parent */ -+ GATE_SGMII0(CK_SGM0_RX_EN, "sgm0_rx_en", CK_TOP_CB_CKSQ_40M, 3), -+}; -+ -+static int mt7988_sgmiisys_0_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, -+ sgmiisys_0_mtk_gate); -+} -+ -+static const struct udevice_id mt7988_sgmiisys_0_compat[] = { -+ { -+ .compatible = "mediatek,mt7988-sgmiisys_0", -+ }, -+ {} -+}; -+ -+U_BOOT_DRIVER(mtk_clk_sgmiisys_0) = { -+ .name = "mt7988-clock-sgmiisys_0", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_sgmiisys_0_compat, -+ .probe = mt7988_sgmiisys_0_probe, -+ .priv_auto = sizeof(struct mtk_cg_priv), -+ .ops = &mtk_clk_gate_ops, -+}; -+ -+/* SGMIISYS_1 */ -+ -+static const struct mtk_gate_regs sgmii1_cg_regs = { -+ .set_ofs = 0xE4, -+ .clr_ofs = 0xE4, -+ .sta_ofs = 0xE4, -+}; -+ -+#define GATE_SGMII1(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = &sgmii1_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ -+ } -+ -+static const struct mtk_gate sgmiisys_1_mtk_gate[] = { -+ /* connect to fake clock, so use CK_TOP_CB_CKSQ_40M as the clock parent */ -+ GATE_SGMII1(CK_SGM1_TX_EN, "sgm1_tx_en", CK_TOP_CB_CKSQ_40M, 2), -+ /* connect to fake clock, so use CK_TOP_CB_CKSQ_40M as the clock parent */ -+ GATE_SGMII1(CK_SGM1_RX_EN, "sgm1_rx_en", CK_TOP_CB_CKSQ_40M, 3), -+}; -+ -+static int mt7988_sgmiisys_1_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, -+ sgmiisys_1_mtk_gate); -+} -+ -+static const struct udevice_id mt7988_sgmiisys_1_compat[] = { -+ { -+ .compatible = "mediatek,mt7988-sgmiisys_1", -+ }, -+ {} -+}; -+ -+U_BOOT_DRIVER(mtk_clk_sgmiisys_1) = { -+ .name = "mt7988-clock-sgmiisys_1", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_sgmiisys_1_compat, -+ .probe = mt7988_sgmiisys_1_probe, -+ .priv_auto = sizeof(struct mtk_cg_priv), -+ .ops = &mtk_clk_gate_ops, -+}; -+ -+/* ETHWARP */ -+ -+static const struct mtk_gate_regs ethwarp_cg_regs = { -+ .set_ofs = 0x14, -+ .clr_ofs = 0x14, -+ .sta_ofs = 0x14, -+}; -+ -+#define GATE_ETHWARP(_id, _name, _parent, _shift) \ -+ { \ -+ .id = _id, .parent = _parent, .regs = ðwarp_cg_regs, \ -+ .shift = _shift, \ -+ .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ -+ } -+ -+static const struct mtk_gate ethwarp_mtk_gate[] = { -+ GATE_ETHWARP(CK_ETHWARP_WOCPU2_EN, "ethwarp_wocpu2_en", -+ CK_TOP_NETSYS_WED_MCU, 13), -+ GATE_ETHWARP(CK_ETHWARP_WOCPU1_EN, "ethwarp_wocpu1_en", -+ CK_TOP_NETSYS_WED_MCU, 14), -+ GATE_ETHWARP(CK_ETHWARP_WOCPU0_EN, "ethwarp_wocpu0_en", -+ CK_TOP_NETSYS_WED_MCU, 15), -+}; -+ -+static int mt7988_ethwarp_probe(struct udevice *dev) -+{ -+ return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, -+ ethwarp_mtk_gate); -+} -+ -+static int mt7988_ethwarp_bind(struct udevice *dev) -+{ -+ int ret = 0; -+ -+ if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { -+ ret = mediatek_reset_bind(dev, MT7988_ETHWARP_RST_CTRL_OFS, 2); -+ if (ret) -+ debug("Warning: failed to bind reset controller\n"); -+ } -+ -+ return ret; -+} -+ -+static const struct udevice_id mt7988_ethwarp_compat[] = { -+ { -+ .compatible = "mediatek,mt7988-ethwarp", -+ }, -+ {} -+}; -+ -+U_BOOT_DRIVER(mtk_clk_ethwarp) = { -+ .name = "mt7988-clock-ethwarp", -+ .id = UCLASS_CLK, -+ .of_match = mt7988_ethwarp_compat, -+ .probe = mt7988_ethwarp_probe, -+ .bind = mt7988_ethwarp_bind, -+ .priv_auto = sizeof(struct mtk_cg_priv), -+ .ops = &mtk_clk_gate_ops, -+}; ---- /dev/null -+++ b/include/dt-bindings/clock/mt7988-clk.h -@@ -0,0 +1,349 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+/* -+ * Copyright (C) 2022 MediaTek Inc. All rights reserved. -+ * -+ * Author: Sam Shih -+ */ -+ -+#ifndef _DT_BINDINGS_CLK_MT7988_H -+#define _DT_BINDINGS_CLK_MT7988_H -+ -+/* INFRACFG */ -+/* mtk_fixed_factor */ -+#define CK_INFRA_CK_F26M 0 -+#define CK_INFRA_PWM_O 1 -+#define CK_INFRA_PCIE_OCC_P0 2 -+#define CK_INFRA_PCIE_OCC_P1 3 -+#define CK_INFRA_PCIE_OCC_P2 4 -+#define CK_INFRA_PCIE_OCC_P3 5 -+#define CK_INFRA_133M_HCK 6 -+#define CK_INFRA_133M_PHCK 7 -+#define CK_INFRA_66M_PHCK 8 -+#define CK_INFRA_FAUD_L_O 9 -+#define CK_INFRA_FAUD_AUD_O 10 -+#define CK_INFRA_FAUD_EG2_O 11 -+#define CK_INFRA_I2C_O 12 -+#define CK_INFRA_UART_O0 13 -+#define CK_INFRA_UART_O1 14 -+#define CK_INFRA_UART_O2 15 -+#define CK_INFRA_NFI_O 16 -+#define CK_INFRA_SPINFI_O 17 -+#define CK_INFRA_SPI0_O 18 -+#define CK_INFRA_SPI1_O 19 -+#define CK_INFRA_LB_MUX_FRTC 20 -+#define CK_INFRA_FRTC 21 -+#define CK_INFRA_FMSDC400_O 22 -+#define CK_INFRA_FMSDC2_HCK_OCC 23 -+#define CK_INFRA_PERI_133M 24 -+#define CK_INFRA_USB_O 25 -+#define CK_INFRA_USB_O_P1 26 -+#define CK_INFRA_USB_FRMCNT_O 27 -+#define CK_INFRA_USB_FRMCNT_O_P1 28 -+#define CK_INFRA_USB_XHCI_O 29 -+#define CK_INFRA_USB_XHCI_O_P1 30 -+#define CK_INFRA_USB_PIPE_O 31 -+#define CK_INFRA_USB_PIPE_O_P1 32 -+#define CK_INFRA_USB_UTMI_O 33 -+#define CK_INFRA_USB_UTMI_O_P1 34 -+#define CK_INFRA_PCIE_PIPE_OCC_P0 35 -+#define CK_INFRA_PCIE_PIPE_OCC_P1 36 -+#define CK_INFRA_PCIE_PIPE_OCC_P2 37 -+#define CK_INFRA_PCIE_PIPE_OCC_P3 38 -+#define CK_INFRA_F26M_O0 39 -+#define CK_INFRA_F26M_O1 40 -+#define CK_INFRA_133M_MCK 41 -+#define CK_INFRA_66M_MCK 42 -+#define CK_INFRA_PERI_66M_O 43 -+#define CK_INFRA_USB_SYS_O 44 -+#define CK_INFRA_USB_SYS_O_P1 45 -+ -+/* INFRACFG_AO */ -+#define GATE_OFFSET 65 -+/* mtk_mux */ -+#define CK_INFRA_MUX_UART0_SEL 46 /* Linux CLK ID (0) */ -+#define CK_INFRA_MUX_UART1_SEL 47 /* Linux CLK ID (1) */ -+#define CK_INFRA_MUX_UART2_SEL 48 /* Linux CLK ID (2) */ -+#define CK_INFRA_MUX_SPI0_SEL 49 /* Linux CLK ID (3) */ -+#define CK_INFRA_MUX_SPI1_SEL 50 /* Linux CLK ID (4) */ -+#define CK_INFRA_MUX_SPI2_SEL 51 /* Linux CLK ID (5) */ -+#define CK_INFRA_PWM_SEL 52 /* Linux CLK ID (6) */ -+#define CK_INFRA_PWM_CK1_SEL 53 /* Linux CLK ID (7) */ -+#define CK_INFRA_PWM_CK2_SEL 54 /* Linux CLK ID (8) */ -+#define CK_INFRA_PWM_CK3_SEL 55 /* Linux CLK ID (9) */ -+#define CK_INFRA_PWM_CK4_SEL 56 /* Linux CLK ID (10) */ -+#define CK_INFRA_PWM_CK5_SEL 57 /* Linux CLK ID (11) */ -+#define CK_INFRA_PWM_CK6_SEL 58 /* Linux CLK ID (12) */ -+#define CK_INFRA_PWM_CK7_SEL 59 /* Linux CLK ID (13) */ -+#define CK_INFRA_PWM_CK8_SEL 60 /* Linux CLK ID (14) */ -+#define CK_INFRA_PCIE_GFMUX_TL_O_P0_SEL 61 /* Linux CLK ID (15) */ -+#define CK_INFRA_PCIE_GFMUX_TL_O_P1_SEL 62 /* Linux CLK ID (16) */ -+#define CK_INFRA_PCIE_GFMUX_TL_O_P2_SEL 63 /* Linux CLK ID (17) */ -+#define CK_INFRA_PCIE_GFMUX_TL_O_P3_SEL 64 /* Linux CLK ID (18) */ -+/* mtk_gate */ -+#define CK_INFRA_66M_GPT_BCK (65 - GATE_OFFSET) /* Linux CLK ID (19) */ -+#define CK_INFRA_66M_PWM_HCK (66 - GATE_OFFSET) /* Linux CLK ID (20) */ -+#define CK_INFRA_66M_PWM_BCK (67 - GATE_OFFSET) /* Linux CLK ID (21) */ -+#define CK_INFRA_66M_PWM_CK1 (68 - GATE_OFFSET) /* Linux CLK ID (22) */ -+#define CK_INFRA_66M_PWM_CK2 (69 - GATE_OFFSET) /* Linux CLK ID (23) */ -+#define CK_INFRA_66M_PWM_CK3 (70 - GATE_OFFSET) /* Linux CLK ID (24) */ -+#define CK_INFRA_66M_PWM_CK4 (71 - GATE_OFFSET) /* Linux CLK ID (25) */ -+#define CK_INFRA_66M_PWM_CK5 (72 - GATE_OFFSET) /* Linux CLK ID (26) */ -+#define CK_INFRA_66M_PWM_CK6 (73 - GATE_OFFSET) /* Linux CLK ID (27) */ -+#define CK_INFRA_66M_PWM_CK7 (74 - GATE_OFFSET) /* Linux CLK ID (28) */ -+#define CK_INFRA_66M_PWM_CK8 (75 - GATE_OFFSET) /* Linux CLK ID (29) */ -+#define CK_INFRA_133M_CQDMA_BCK (76 - GATE_OFFSET) /* Linux CLK ID (30) */ -+#define CK_INFRA_66M_AUD_SLV_BCK (77 - GATE_OFFSET) /* Linux CLK ID (31) */ -+#define CK_INFRA_AUD_26M (78 - GATE_OFFSET) /* Linux CLK ID (32) */ -+#define CK_INFRA_AUD_L (79 - GATE_OFFSET) /* Linux CLK ID (33) */ -+#define CK_INFRA_AUD_AUD (80 - GATE_OFFSET) /* Linux CLK ID (34) */ -+#define CK_INFRA_AUD_EG2 (81 - GATE_OFFSET) /* Linux CLK ID (35) */ -+#define CK_INFRA_DRAMC_F26M (82 - GATE_OFFSET) /* Linux CLK ID (36) */ -+#define CK_INFRA_133M_DBG_ACKM (83 - GATE_OFFSET) /* Linux CLK ID (37) */ -+#define CK_INFRA_66M_AP_DMA_BCK (84 - GATE_OFFSET) /* Linux CLK ID (38) */ -+#define CK_INFRA_66M_SEJ_BCK (85 - GATE_OFFSET) /* Linux CLK ID (39) */ -+#define CK_INFRA_PRE_CK_SEJ_F13M (86 - GATE_OFFSET) /* Linux CLK ID (40) */ -+#define CK_INFRA_66M_TRNG (87 - GATE_OFFSET) /* Linux CLK ID (41) */ -+#define CK_INFRA_26M_THERM_SYSTEM (88 - GATE_OFFSET) /* Linux CLK ID (42) */ -+#define CK_INFRA_I2C_BCK (89 - GATE_OFFSET) /* Linux CLK ID (43) */ -+#define CK_INFRA_66M_UART0_PCK (90 - GATE_OFFSET) /* Linux CLK ID (44) */ -+#define CK_INFRA_66M_UART1_PCK (91 - GATE_OFFSET) /* Linux CLK ID (45) */ -+#define CK_INFRA_66M_UART2_PCK (92 - GATE_OFFSET) /* Linux CLK ID (46) */ -+#define CK_INFRA_52M_UART0_CK (93 - GATE_OFFSET) /* Linux CLK ID (47) */ -+#define CK_INFRA_52M_UART1_CK (94 - GATE_OFFSET) /* Linux CLK ID (48) */ -+#define CK_INFRA_52M_UART2_CK (95 - GATE_OFFSET) /* Linux CLK ID (49) */ -+#define CK_INFRA_NFI (96 - GATE_OFFSET) /* Linux CLK ID (50) */ -+#define CK_INFRA_SPINFI (97 - GATE_OFFSET) /* Linux CLK ID (51) */ -+#define CK_INFRA_66M_NFI_HCK (98 - GATE_OFFSET) /* Linux CLK ID (52) */ -+#define CK_INFRA_104M_SPI0 (99 - GATE_OFFSET) /* Linux CLK ID (53) */ -+#define CK_INFRA_104M_SPI1 (100 - GATE_OFFSET) /* Linux CLK ID (54) */ -+#define CK_INFRA_104M_SPI2_BCK (101 - GATE_OFFSET) /* Linux CLK ID (55) */ -+#define CK_INFRA_66M_SPI0_HCK (102 - GATE_OFFSET) /* Linux CLK ID (56) */ -+#define CK_INFRA_66M_SPI1_HCK (103 - GATE_OFFSET) /* Linux CLK ID (57) */ -+#define CK_INFRA_66M_SPI2_HCK (104 - GATE_OFFSET) /* Linux CLK ID (58) */ -+#define CK_INFRA_66M_FLASHIF_AXI (105 - GATE_OFFSET) /* Linux CLK ID (59) */ -+#define CK_INFRA_RTC (106 - GATE_OFFSET) /* Linux CLK ID (60) */ -+#define CK_INFRA_26M_ADC_BCK (107 - GATE_OFFSET) /* Linux CLK ID (61) */ -+#define CK_INFRA_RC_ADC (108 - GATE_OFFSET) /* Linux CLK ID (62) */ -+#define CK_INFRA_MSDC400 (109 - GATE_OFFSET) /* Linux CLK ID (63) */ -+#define CK_INFRA_MSDC2_HCK (110 - GATE_OFFSET) /* Linux CLK ID (64) */ -+#define CK_INFRA_133M_MSDC_0_HCK (111 - GATE_OFFSET) /* Linux CLK ID (65) */ -+#define CK_INFRA_66M_MSDC_0_HCK (112 - GATE_OFFSET) /* Linux CLK ID (66) */ -+#define CK_INFRA_133M_CPUM_BCK (113 - GATE_OFFSET) /* Linux CLK ID (67) */ -+#define CK_INFRA_BIST2FPC (114 - GATE_OFFSET) /* Linux CLK ID (68) */ -+#define CK_INFRA_I2C_X16W_MCK_CK_P1 (115 - GATE_OFFSET) /* Linux CLK ID (69) */ -+#define CK_INFRA_I2C_X16W_PCK_CK_P1 (116 - GATE_OFFSET) /* Linux CLK ID (70) */ -+#define CK_INFRA_133M_USB_HCK (117 - GATE_OFFSET) /* Linux CLK ID (71) */ -+#define CK_INFRA_133M_USB_HCK_CK_P1 (118 - GATE_OFFSET) /* Linux CLK ID (72) */ -+#define CK_INFRA_66M_USB_HCK (119 - GATE_OFFSET) /* Linux CLK ID (73) */ -+#define CK_INFRA_66M_USB_HCK_CK_P1 (120 - GATE_OFFSET) /* Linux CLK ID (74) */ -+#define CK_INFRA_USB_SYS (121 - GATE_OFFSET) /* Linux CLK ID (75) */ -+#define CK_INFRA_USB_SYS_CK_P1 (122 - GATE_OFFSET) /* Linux CLK ID (76) */ -+#define CK_INFRA_USB_REF (123 - GATE_OFFSET) /* Linux CLK ID (77) */ -+#define CK_INFRA_USB_CK_P1 (124 - GATE_OFFSET) /* Linux CLK ID (78) */ -+#define CK_INFRA_USB_FRMCNT (125 - GATE_OFFSET) /* Linux CLK ID (79) */ -+#define CK_INFRA_USB_FRMCNT_CK_P1 (126 - GATE_OFFSET) /* Linux CLK ID (80) */ -+#define CK_INFRA_USB_PIPE (127 - GATE_OFFSET) /* Linux CLK ID (81) */ -+#define CK_INFRA_USB_PIPE_CK_P1 (128 - GATE_OFFSET) /* Linux CLK ID (82) */ -+#define CK_INFRA_USB_UTMI (129 - GATE_OFFSET) /* Linux CLK ID (83) */ -+#define CK_INFRA_USB_UTMI_CK_P1 (130 - GATE_OFFSET) /* Linux CLK ID (84) */ -+#define CK_INFRA_USB_XHCI (131 - GATE_OFFSET) /* Linux CLK ID (85) */ -+#define CK_INFRA_USB_XHCI_CK_P1 (132 - GATE_OFFSET) /* Linux CLK ID (86) */ -+#define CK_INFRA_PCIE_GFMUX_TL_P0 (133 - GATE_OFFSET) /* Linux CLK ID (87) */ -+#define CK_INFRA_PCIE_GFMUX_TL_P1 (134 - GATE_OFFSET) /* Linux CLK ID (88) */ -+#define CK_INFRA_PCIE_GFMUX_TL_P2 (135 - GATE_OFFSET) /* Linux CLK ID (89) */ -+#define CK_INFRA_PCIE_GFMUX_TL_P3 (136 - GATE_OFFSET) /* Linux CLK ID (90) */ -+#define CK_INFRA_PCIE_PIPE_P0 (137 - GATE_OFFSET) /* Linux CLK ID (91) */ -+#define CK_INFRA_PCIE_PIPE_P1 (138 - GATE_OFFSET) /* Linux CLK ID (92) */ -+#define CK_INFRA_PCIE_PIPE_P2 (139 - GATE_OFFSET) /* Linux CLK ID (93) */ -+#define CK_INFRA_PCIE_PIPE_P3 (140 - GATE_OFFSET) /* Linux CLK ID (94) */ -+#define CK_INFRA_133M_PCIE_CK_P0 (141 - GATE_OFFSET) /* Linux CLK ID (95) */ -+#define CK_INFRA_133M_PCIE_CK_P1 (142 - GATE_OFFSET) /* Linux CLK ID (96) */ -+#define CK_INFRA_133M_PCIE_CK_P2 (143 - GATE_OFFSET) /* Linux CLK ID (97) */ -+#define CK_INFRA_133M_PCIE_CK_P3 (144 - GATE_OFFSET) /* Linux CLK ID (98) */ -+#define CK_INFRA_PCIE_PERI_26M_CK_P0 (145 - GATE_OFFSET) /* Linux CLK ID (99) */ -+#define CK_INFRA_PCIE_PERI_26M_CK_P1 \ -+ (146 - GATE_OFFSET) /* Linux CLK ID (100) */ -+#define CK_INFRA_PCIE_PERI_26M_CK_P2 \ -+ (147 - GATE_OFFSET) /* Linux CLK ID (101) */ -+#define CK_INFRA_PCIE_PERI_26M_CK_P3 \ -+ (148 - GATE_OFFSET) /* Linux CLK ID (102) */ -+ -+/* TOPCKGEN */ -+/* mtk_fixed_factor */ -+#define CK_TOP_CB_CKSQ_40M 0 /* Linux CLK ID (74) */ -+#define CK_TOP_CB_M_416M 1 /* Linux CLK ID (75) */ -+#define CK_TOP_CB_M_D2 2 /* Linux CLK ID (76) */ -+#define CK_TOP_M_D3_D2 3 /* Linux CLK ID (77) */ -+#define CK_TOP_CB_M_D4 4 /* Linux CLK ID (78) */ -+#define CK_TOP_CB_M_D8 5 /* Linux CLK ID (79) */ -+#define CK_TOP_M_D8_D2 6 /* Linux CLK ID (80) */ -+#define CK_TOP_CB_MM_720M 7 /* Linux CLK ID (81) */ -+#define CK_TOP_CB_MM_D2 8 /* Linux CLK ID (82) */ -+#define CK_TOP_CB_MM_D3_D5 9 /* Linux CLK ID (83) */ -+#define CK_TOP_CB_MM_D4 10 /* Linux CLK ID (84) */ -+#define CK_TOP_MM_D6_D2 11 /* Linux CLK ID (85) */ -+#define CK_TOP_CB_MM_D8 12 /* Linux CLK ID (86) */ -+#define CK_TOP_CB_APLL2_196M 13 /* Linux CLK ID (87) */ -+#define CK_TOP_CB_APLL2_D4 14 /* Linux CLK ID (88) */ -+#define CK_TOP_CB_NET1_D4 15 /* Linux CLK ID (89) */ -+#define CK_TOP_CB_NET1_D5 16 /* Linux CLK ID (90) */ -+#define CK_TOP_NET1_D5_D2 17 /* Linux CLK ID (91) */ -+#define CK_TOP_NET1_D5_D4 18 /* Linux CLK ID (92) */ -+#define CK_TOP_CB_NET1_D8 19 /* Linux CLK ID (93) */ -+#define CK_TOP_NET1_D8_D2 20 /* Linux CLK ID (94) */ -+#define CK_TOP_NET1_D8_D4 21 /* Linux CLK ID (95) */ -+#define CK_TOP_NET1_D8_D8 22 /* Linux CLK ID (96) */ -+#define CK_TOP_NET1_D8_D16 23 /* Linux CLK ID (97) */ -+#define CK_TOP_CB_NET2_800M 24 /* Linux CLK ID (98) */ -+#define CK_TOP_CB_NET2_D2 25 /* Linux CLK ID (99) */ -+#define CK_TOP_CB_NET2_D4 26 /* Linux CLK ID (100) */ -+#define CK_TOP_NET2_D4_D4 27 /* Linux CLK ID (101) */ -+#define CK_TOP_NET2_D4_D8 28 /* Linux CLK ID (102) */ -+#define CK_TOP_CB_NET2_D6 29 /* Linux CLK ID (103) */ -+#define CK_TOP_CB_NET2_D8 30 /* Linux CLK ID (104) */ -+#define CK_TOP_CB_WEDMCU_208M 31 /* Linux CLK ID (105) */ -+#define CK_TOP_CB_SGM_325M 32 /* Linux CLK ID (106) */ -+#define CK_TOP_CB_NETSYS_850M 33 /* Linux CLK ID (107) */ -+#define CK_TOP_CB_MSDC_400M 34 /* Linux CLK ID (108) */ -+#define CK_TOP_CKSQ_40M_D2 35 /* Linux CLK ID (109) */ -+#define CK_TOP_CB_RTC_32K 36 /* Linux CLK ID (110) */ -+#define CK_TOP_CB_RTC_32P7K 37 /* Linux CLK ID (111) */ -+#define CK_TOP_INFRA_F32K 38 /* Linux CLK ID (112) */ -+#define CK_TOP_CKSQ_SRC 39 /* Linux CLK ID (113) */ -+#define CK_TOP_NETSYS_2X 40 /* Linux CLK ID (114) */ -+#define CK_TOP_NETSYS_GSW 41 /* Linux CLK ID (115) */ -+#define CK_TOP_NETSYS_WED_MCU 42 /* Linux CLK ID (116) */ -+#define CK_TOP_EIP197 43 /* Linux CLK ID (117) */ -+#define CK_TOP_EMMC_250M 44 /* Linux CLK ID (118) */ -+#define CK_TOP_EMMC_400M 45 /* Linux CLK ID (119) */ -+#define CK_TOP_SPI 46 /* Linux CLK ID (120) */ -+#define CK_TOP_SPIM_MST 47 /* Linux CLK ID (121) */ -+#define CK_TOP_NFI1X 48 /* Linux CLK ID (122) */ -+#define CK_TOP_SPINFI_BCK 49 /* Linux CLK ID (123) */ -+#define CK_TOP_I2C_BCK 50 /* Linux CLK ID (124) */ -+#define CK_TOP_USB_SYS 51 /* Linux CLK ID (125) */ -+#define CK_TOP_USB_SYS_P1 52 /* Linux CLK ID (126) */ -+#define CK_TOP_USB_XHCI 53 /* Linux CLK ID (127) */ -+#define CK_TOP_USB_XHCI_P1 54 /* Linux CLK ID (128) */ -+#define CK_TOP_USB_FRMCNT 55 /* Linux CLK ID (129) */ -+#define CK_TOP_USB_FRMCNT_P1 56 /* Linux CLK ID (130) */ -+#define CK_TOP_AUD 57 /* Linux CLK ID (131) */ -+#define CK_TOP_A1SYS 58 /* Linux CLK ID (132) */ -+#define CK_TOP_AUD_L 59 /* Linux CLK ID (133) */ -+#define CK_TOP_A_TUNER 60 /* Linux CLK ID (134) */ -+#define CK_TOP_SYSAXI 61 /* Linux CLK ID (135) */ -+#define CK_TOP_INFRA_F26M 62 /* Linux CLK ID (136) */ -+#define CK_TOP_USB_REF 63 /* Linux CLK ID (137) */ -+#define CK_TOP_USB_CK_P1 64 /* Linux CLK ID (138) */ -+/* mtk_mux */ -+#define CK_TOP_NETSYS_SEL 65 /* Linux CLK ID (0) */ -+#define CK_TOP_NETSYS_500M_SEL 66 /* Linux CLK ID (1) */ -+#define CK_TOP_NETSYS_2X_SEL 67 /* Linux CLK ID (2) */ -+#define CK_TOP_NETSYS_GSW_SEL 68 /* Linux CLK ID (3) */ -+#define CK_TOP_ETH_GMII_SEL 69 /* Linux CLK ID (4) */ -+#define CK_TOP_NETSYS_MCU_SEL 70 /* Linux CLK ID (5) */ -+#define CK_TOP_NETSYS_PAO_2X_SEL 71 /* Linux CLK ID (6) */ -+#define CK_TOP_EIP197_SEL 72 /* Linux CLK ID (7) */ -+#define CK_TOP_AXI_INFRA_SEL 73 /* Linux CLK ID (8) */ -+#define CK_TOP_UART_SEL 74 /* Linux CLK ID (9) */ -+#define CK_TOP_EMMC_250M_SEL 75 /* Linux CLK ID (10) */ -+#define CK_TOP_EMMC_400M_SEL 76 /* Linux CLK ID (11) */ -+#define CK_TOP_SPI_SEL 77 /* Linux CLK ID (12) */ -+#define CK_TOP_SPIM_MST_SEL 78 /* Linux CLK ID (13) */ -+#define CK_TOP_NFI1X_SEL 79 /* Linux CLK ID (14) */ -+#define CK_TOP_SPINFI_SEL 80 /* Linux CLK ID (15) */ -+#define CK_TOP_PWM_SEL 81 /* Linux CLK ID (16) */ -+#define CK_TOP_I2C_SEL 82 /* Linux CLK ID (17) */ -+#define CK_TOP_PCIE_MBIST_250M_SEL 83 /* Linux CLK ID (18) */ -+#define CK_TOP_PEXTP_TL_SEL 84 /* Linux CLK ID (19) */ -+#define CK_TOP_PEXTP_TL_P1_SEL 85 /* Linux CLK ID (20) */ -+#define CK_TOP_PEXTP_TL_P2_SEL 86 /* Linux CLK ID (21) */ -+#define CK_TOP_PEXTP_TL_P3_SEL 87 /* Linux CLK ID (22) */ -+#define CK_TOP_USB_SYS_SEL 88 /* Linux CLK ID (23) */ -+#define CK_TOP_USB_SYS_P1_SEL 89 /* Linux CLK ID (24) */ -+#define CK_TOP_USB_XHCI_SEL 90 /* Linux CLK ID (25) */ -+#define CK_TOP_USB_XHCI_P1_SEL 91 /* Linux CLK ID (26) */ -+#define CK_TOP_USB_FRMCNT_SEL 92 /* Linux CLK ID (27) */ -+#define CK_TOP_USB_FRMCNT_P1_SEL 93 /* Linux CLK ID (28) */ -+#define CK_TOP_AUD_SEL 94 /* Linux CLK ID (29) */ -+#define CK_TOP_A1SYS_SEL 95 /* Linux CLK ID (30) */ -+#define CK_TOP_AUD_L_SEL 96 /* Linux CLK ID (31) */ -+#define CK_TOP_A_TUNER_SEL 97 /* Linux CLK ID (32) */ -+#define CK_TOP_SSPXTP_SEL 98 /* Linux CLK ID (33) */ -+#define CK_TOP_USB_PHY_SEL 99 /* Linux CLK ID (34) */ -+#define CK_TOP_USXGMII_SBUS_0_SEL 100 /* Linux CLK ID (35) */ -+#define CK_TOP_USXGMII_SBUS_1_SEL 101 /* Linux CLK ID (36) */ -+#define CK_TOP_SGM_0_SEL 102 /* Linux CLK ID (37) */ -+#define CK_TOP_SGM_SBUS_0_SEL 103 /* Linux CLK ID (38) */ -+#define CK_TOP_SGM_1_SEL 104 /* Linux CLK ID (39) */ -+#define CK_TOP_SGM_SBUS_1_SEL 105 /* Linux CLK ID (40) */ -+#define CK_TOP_XFI_PHY_0_XTAL_SEL 106 /* Linux CLK ID (41) */ -+#define CK_TOP_XFI_PHY_1_XTAL_SEL 107 /* Linux CLK ID (42) */ -+#define CK_TOP_SYSAXI_SEL 108 /* Linux CLK ID (43) */ -+#define CK_TOP_SYSAPB_SEL 109 /* Linux CLK ID (44) */ -+#define CK_TOP_ETH_REFCK_50M_SEL 110 /* Linux CLK ID (45) */ -+#define CK_TOP_ETH_SYS_200M_SEL 111 /* Linux CLK ID (46) */ -+#define CK_TOP_ETH_SYS_SEL 112 /* Linux CLK ID (47) */ -+#define CK_TOP_ETH_XGMII_SEL 113 /* Linux CLK ID (48) */ -+#define CK_TOP_BUS_TOPS_SEL 114 /* Linux CLK ID (49) */ -+#define CK_TOP_NPU_TOPS_SEL 115 /* Linux CLK ID (50) */ -+#define CK_TOP_DRAMC_SEL 116 /* Linux CLK ID (51) */ -+#define CK_TOP_DRAMC_MD32_SEL 117 /* Linux CLK ID (52) */ -+#define CK_TOP_INFRA_F26M_SEL 118 /* Linux CLK ID (53) */ -+#define CK_TOP_PEXTP_P0_SEL 119 /* Linux CLK ID (54) */ -+#define CK_TOP_PEXTP_P1_SEL 120 /* Linux CLK ID (55) */ -+#define CK_TOP_PEXTP_P2_SEL 121 /* Linux CLK ID (56) */ -+#define CK_TOP_PEXTP_P3_SEL 122 /* Linux CLK ID (57) */ -+#define CK_TOP_DA_XTP_GLB_P0_SEL 123 /* Linux CLK ID (58) */ -+#define CK_TOP_DA_XTP_GLB_P1_SEL 124 /* Linux CLK ID (59) */ -+#define CK_TOP_DA_XTP_GLB_P2_SEL 125 /* Linux CLK ID (60) */ -+#define CK_TOP_DA_XTP_GLB_P3_SEL 126 /* Linux CLK ID (61) */ -+#define CK_TOP_CKM_SEL 127 /* Linux CLK ID (62) */ -+#define CK_TOP_DA_SELM_XTAL_SEL 128 /* Linux CLK ID (63) */ -+#define CK_TOP_PEXTP_SEL 129 /* Linux CLK ID (64) */ -+#define CK_TOP_TOPS_P2_26M_SEL 130 /* Linux CLK ID (65) */ -+#define CK_TOP_MCUSYS_BACKUP_625M_SEL 131 /* Linux CLK ID (66) */ -+#define CK_TOP_NETSYS_SYNC_250M_SEL 132 /* Linux CLK ID (67) */ -+#define CK_TOP_MACSEC_SEL 133 /* Linux CLK ID (68) */ -+#define CK_TOP_NETSYS_TOPS_400M_SEL 134 /* Linux CLK ID (69) */ -+#define CK_TOP_NETSYS_PPEFB_250M_SEL 135 /* Linux CLK ID (70) */ -+#define CK_TOP_NETSYS_WARP_SEL 136 /* Linux CLK ID (71) */ -+#define CK_TOP_ETH_MII_SEL 137 /* Linux CLK ID (72) */ -+#define CK_TOP_CK_NPU_SEL_CM_TOPS_SEL 138 /* Linux CLK ID (73) */ -+ -+/* APMIXEDSYS */ -+/* mtk_pll_data */ -+#define CK_APMIXED_NETSYSPLL 0 -+#define CK_APMIXED_MPLL 1 -+#define CK_APMIXED_MMPLL 2 -+#define CK_APMIXED_APLL2 3 -+#define CK_APMIXED_NET1PLL 4 -+#define CK_APMIXED_NET2PLL 5 -+#define CK_APMIXED_WEDMCUPLL 6 -+#define CK_APMIXED_SGMPLL 7 -+#define CK_APMIXED_ARM_B 8 -+#define CK_APMIXED_CCIPLL2_B 9 -+#define CK_APMIXED_USXGMIIPLL 10 -+#define CK_APMIXED_MSDCPLL 11 -+ -+/* ETHSYS ETH DMA */ -+/* mtk_gate */ -+#define CK_ETHDMA_FE_EN 0 -+ -+/* SGMIISYS_0 */ -+/* mtk_gate */ -+#define CK_SGM0_TX_EN 0 -+#define CK_SGM0_RX_EN 1 -+ -+/* SGMIISYS_1 */ -+/* mtk_gate */ -+#define CK_SGM1_TX_EN 0 -+#define CK_SGM1_RX_EN 1 -+ -+/* ETHWARP */ -+/* mtk_gate */ -+#define CK_ETHWARP_WOCPU2_EN 0 -+#define CK_ETHWARP_WOCPU1_EN 1 -+#define CK_ETHWARP_WOCPU0_EN 2 -+ -+#endif /* _DT_BINDINGS_CLK_MT7988_H */ diff --git a/package/boot/uboot-mediatek/patches/101-11-reset-mediatek-add-reset-definition-for-MediaTek-MT7.patch b/package/boot/uboot-mediatek/patches/101-11-reset-mediatek-add-reset-definition-for-MediaTek-MT7.patch deleted file mode 100644 index f14c38363874bf..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-11-reset-mediatek-add-reset-definition-for-MediaTek-MT7.patch +++ /dev/null @@ -1,49 +0,0 @@ -From b4a308dd31a7c6754be230849a5e430052268b9c Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:33 +0800 -Subject: [PATCH 11/29] reset: mediatek: add reset definition for MediaTek - MT7988 SoC - -This patch adds reset bits for MediaTek MT7988 - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - include/dt-bindings/reset/mt7988-reset.h | 31 ++++++++++++++++++++++++ - 1 file changed, 31 insertions(+) - create mode 100644 include/dt-bindings/reset/mt7988-reset.h - ---- /dev/null -+++ b/include/dt-bindings/reset/mt7988-reset.h -@@ -0,0 +1,31 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+/* -+ * Copyright (C) 2023 MediaTek Inc. -+ */ -+ -+#ifndef _DT_BINDINGS_MTK_RESET_H_ -+#define _DT_BINDINGS_MTK_RESET_H_ -+ -+/* ETHDMA Subsystem resets */ -+#define ETHDMA_FE_RST 6 -+#define ETHDMA_PMTR_RST 8 -+#define ETHDMA_GMAC_RST 23 -+#define ETHDMA_WDMA0_RST 24 -+#define ETHDMA_WDMA1_RST 25 -+#define ETHDMA_WDMA2_RST 26 -+#define ETHDMA_PPE0_RST 29 -+#define ETHDMA_PPE1_RST 30 -+#define ETHDMA_PPE2_RST 31 -+ -+/* ETHWARP Subsystem resets */ -+#define ETHWARP_GSW_RST 9 -+#define ETHWARP_EIP197_RST 10 -+#define ETHWARP_WOCPU0_RST 32 -+#define ETHWARP_WOCPU1_RST 33 -+#define ETHWARP_WOCPU2_RST 34 -+#define ETHWARP_WOX_NET_MUX_RST 35 -+#define ETHWARP_WED0_RST 36 -+#define ETHWARP_WED1_RST 37 -+#define ETHWARP_WED2_RST 38 -+ -+#endif /* _DT_BINDINGS_MTK_RESET_H_ */ diff --git a/package/boot/uboot-mediatek/patches/101-12-pinctrl-mediatek-convert-most-definitions-to-const.patch b/package/boot/uboot-mediatek/patches/101-12-pinctrl-mediatek-convert-most-definitions-to-const.patch deleted file mode 100644 index 4085f1154199ce..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-12-pinctrl-mediatek-convert-most-definitions-to-const.patch +++ /dev/null @@ -1,2267 +0,0 @@ -From 30227fcf55ac95ad6778de2fc3e6d1e00cf82566 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:37 +0800 -Subject: [PATCH 12/29] pinctrl: mediatek: convert most definitions to const - -There exists a situation of the mediatek pinctrl driver that may return -wrong pin function value for the pinmux driver: -- All pin function arrays are defined without const -- Some pin function arrays contain all-zero value, e.g.: - static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, }; -- These arrays will be put into .bss section during compilation -- .bss section has no "a" attribute and does not exist in the final binary - file after objcopy. -- FDT binary blob is appended to the u-boot binary, which occupies the - .bss section. -- During board_f stage, .bss has not been initialized, and contains the - data of FDT, which is not full-zero data. -- pinctrl driver is initialized in board_f stage, and it will get wrong - data if another driver is going to set default pinctrl. - -Since pinmux information and soc data are only meant to be read-only, thus -should be declared as const. This will force all pinctrl data being put -into .rodata section. Since .rodata has "a" attribute, even the all-zero -data will be allocated and filled with correct value in to u-boot binary. - -Signed-off-by: Weijie Gao ---- - drivers/pinctrl/mediatek/pinctrl-mt7622.c | 474 ++++++------- - drivers/pinctrl/mediatek/pinctrl-mt7623.c | 650 +++++++++--------- - drivers/pinctrl/mediatek/pinctrl-mt7629.c | 174 ++--- - drivers/pinctrl/mediatek/pinctrl-mt7981.c | 270 ++++---- - drivers/pinctrl/mediatek/pinctrl-mt7986.c | 145 ++-- - drivers/pinctrl/mediatek/pinctrl-mt8512.c | 24 +- - drivers/pinctrl/mediatek/pinctrl-mt8516.c | 18 +- - drivers/pinctrl/mediatek/pinctrl-mt8518.c | 20 +- - drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 +- - drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 8 +- - 10 files changed, 898 insertions(+), 889 deletions(-) - ---- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c -@@ -233,283 +233,285 @@ static const struct mtk_pin_desc mt7622_ - */ - - /* EMMC */ --static int mt7622_emmc_pins[] = { 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, }; --static int mt7622_emmc_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; -+static const int mt7622_emmc_pins[] = { -+ 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, }; -+static const int mt7622_emmc_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; - --static int mt7622_emmc_rst_pins[] = { 37, }; --static int mt7622_emmc_rst_funcs[] = { 1, }; -+static const int mt7622_emmc_rst_pins[] = { 37, }; -+static const int mt7622_emmc_rst_funcs[] = { 1, }; - - /* LED for EPHY */ --static int mt7622_ephy_leds_pins[] = { 86, 91, 92, 93, 94, }; --static int mt7622_ephy_leds_funcs[] = { 0, 0, 0, 0, 0, }; --static int mt7622_ephy0_led_pins[] = { 86, }; --static int mt7622_ephy0_led_funcs[] = { 0, }; --static int mt7622_ephy1_led_pins[] = { 91, }; --static int mt7622_ephy1_led_funcs[] = { 2, }; --static int mt7622_ephy2_led_pins[] = { 92, }; --static int mt7622_ephy2_led_funcs[] = { 2, }; --static int mt7622_ephy3_led_pins[] = { 93, }; --static int mt7622_ephy3_led_funcs[] = { 2, }; --static int mt7622_ephy4_led_pins[] = { 94, }; --static int mt7622_ephy4_led_funcs[] = { 2, }; -+static const int mt7622_ephy_leds_pins[] = { 86, 91, 92, 93, 94, }; -+static const int mt7622_ephy_leds_funcs[] = { 0, 0, 0, 0, 0, }; -+static const int mt7622_ephy0_led_pins[] = { 86, }; -+static const int mt7622_ephy0_led_funcs[] = { 0, }; -+static const int mt7622_ephy1_led_pins[] = { 91, }; -+static const int mt7622_ephy1_led_funcs[] = { 2, }; -+static const int mt7622_ephy2_led_pins[] = { 92, }; -+static const int mt7622_ephy2_led_funcs[] = { 2, }; -+static const int mt7622_ephy3_led_pins[] = { 93, }; -+static const int mt7622_ephy3_led_funcs[] = { 2, }; -+static const int mt7622_ephy4_led_pins[] = { 94, }; -+static const int mt7622_ephy4_led_funcs[] = { 2, }; - - /* Embedded Switch */ --static int mt7622_esw_pins[] = { 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -- 62, 63, 64, 65, 66, 67, 68, 69, 70, }; --static int mt7622_esw_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0, 0, 0, 0, 0, 0, 0, 0, 0, }; --static int mt7622_esw_p0_p1_pins[] = { 51, 52, 53, 54, 55, 56, 57, 58, }; --static int mt7622_esw_p0_p1_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; --static int mt7622_esw_p2_p3_p4_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66, 67, -- 68, 69, 70, }; --static int mt7622_esw_p2_p3_p4_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0, 0, 0, }; -+static const int mt7622_esw_pins[] = { -+ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, -+ 69, 70, }; -+static const int mt7622_esw_funcs[] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -+static const int mt7622_esw_p0_p1_pins[] = { 51, 52, 53, 54, 55, 56, 57, 58, }; -+static const int mt7622_esw_p0_p1_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; -+static const int mt7622_esw_p2_p3_p4_pins[] = { -+ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, }; -+static const int mt7622_esw_p2_p3_p4_funcs[] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - /* RGMII via ESW */ --static int mt7622_rgmii_via_esw_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66, -- 67, 68, 69, 70, }; --static int mt7622_rgmii_via_esw_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0, }; -+static const int mt7622_rgmii_via_esw_pins[] = { -+ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, }; -+static const int mt7622_rgmii_via_esw_funcs[] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - - /* RGMII via GMAC1 */ --static int mt7622_rgmii_via_gmac1_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66, -- 67, 68, 69, 70, }; --static int mt7622_rgmii_via_gmac1_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -- 2, }; -+static const int mt7622_rgmii_via_gmac1_pins[] = { -+ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, }; -+static const int mt7622_rgmii_via_gmac1_funcs[] = { -+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; - - /* RGMII via GMAC2 */ --static int mt7622_rgmii_via_gmac2_pins[] = { 25, 26, 27, 28, 29, 30, 31, 32, -- 33, 34, 35, 36, }; --static int mt7622_rgmii_via_gmac2_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0, }; -+static const int mt7622_rgmii_via_gmac2_pins[] = { -+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, }; -+static const int mt7622_rgmii_via_gmac2_funcs[] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - - /* I2C */ --static int mt7622_i2c0_pins[] = { 14, 15, }; --static int mt7622_i2c0_funcs[] = { 0, 0, }; --static int mt7622_i2c1_0_pins[] = { 55, 56, }; --static int mt7622_i2c1_0_funcs[] = { 0, 0, }; --static int mt7622_i2c1_1_pins[] = { 73, 74, }; --static int mt7622_i2c1_1_funcs[] = { 3, 3, }; --static int mt7622_i2c1_2_pins[] = { 87, 88, }; --static int mt7622_i2c1_2_funcs[] = { 0, 0, }; --static int mt7622_i2c2_0_pins[] = { 57, 58, }; --static int mt7622_i2c2_0_funcs[] = { 0, 0, }; --static int mt7622_i2c2_1_pins[] = { 75, 76, }; --static int mt7622_i2c2_1_funcs[] = { 3, 3, }; --static int mt7622_i2c2_2_pins[] = { 89, 90, }; --static int mt7622_i2c2_2_funcs[] = { 0, 0, }; -+static const int mt7622_i2c0_pins[] = { 14, 15, }; -+static const int mt7622_i2c0_funcs[] = { 0, 0, }; -+static const int mt7622_i2c1_0_pins[] = { 55, 56, }; -+static const int mt7622_i2c1_0_funcs[] = { 0, 0, }; -+static const int mt7622_i2c1_1_pins[] = { 73, 74, }; -+static const int mt7622_i2c1_1_funcs[] = { 3, 3, }; -+static const int mt7622_i2c1_2_pins[] = { 87, 88, }; -+static const int mt7622_i2c1_2_funcs[] = { 0, 0, }; -+static const int mt7622_i2c2_0_pins[] = { 57, 58, }; -+static const int mt7622_i2c2_0_funcs[] = { 0, 0, }; -+static const int mt7622_i2c2_1_pins[] = { 75, 76, }; -+static const int mt7622_i2c2_1_funcs[] = { 3, 3, }; -+static const int mt7622_i2c2_2_pins[] = { 89, 90, }; -+static const int mt7622_i2c2_2_funcs[] = { 0, 0, }; - - /* I2S */ --static int mt7622_i2s_in_mclk_bclk_ws_pins[] = { 3, 4, 5, }; --static int mt7622_i2s_in_mclk_bclk_ws_funcs[] = { 3, 3, 0, }; --static int mt7622_i2s1_in_data_pins[] = { 1, }; --static int mt7622_i2s1_in_data_funcs[] = { 0, }; --static int mt7622_i2s2_in_data_pins[] = { 16, }; --static int mt7622_i2s2_in_data_funcs[] = { 0, }; --static int mt7622_i2s3_in_data_pins[] = { 17, }; --static int mt7622_i2s3_in_data_funcs[] = { 0, }; --static int mt7622_i2s4_in_data_pins[] = { 18, }; --static int mt7622_i2s4_in_data_funcs[] = { 0, }; --static int mt7622_i2s_out_mclk_bclk_ws_pins[] = { 3, 4, 5, }; --static int mt7622_i2s_out_mclk_bclk_ws_funcs[] = { 0, 0, 0, }; --static int mt7622_i2s1_out_data_pins[] = { 2, }; --static int mt7622_i2s1_out_data_funcs[] = { 0, }; --static int mt7622_i2s2_out_data_pins[] = { 19, }; --static int mt7622_i2s2_out_data_funcs[] = { 0, }; --static int mt7622_i2s3_out_data_pins[] = { 20, }; --static int mt7622_i2s3_out_data_funcs[] = { 0, }; --static int mt7622_i2s4_out_data_pins[] = { 21, }; --static int mt7622_i2s4_out_data_funcs[] = { 0, }; -+static const int mt7622_i2s_in_mclk_bclk_ws_pins[] = { 3, 4, 5, }; -+static const int mt7622_i2s_in_mclk_bclk_ws_funcs[] = { 3, 3, 0, }; -+static const int mt7622_i2s1_in_data_pins[] = { 1, }; -+static const int mt7622_i2s1_in_data_funcs[] = { 0, }; -+static const int mt7622_i2s2_in_data_pins[] = { 16, }; -+static const int mt7622_i2s2_in_data_funcs[] = { 0, }; -+static const int mt7622_i2s3_in_data_pins[] = { 17, }; -+static const int mt7622_i2s3_in_data_funcs[] = { 0, }; -+static const int mt7622_i2s4_in_data_pins[] = { 18, }; -+static const int mt7622_i2s4_in_data_funcs[] = { 0, }; -+static const int mt7622_i2s_out_mclk_bclk_ws_pins[] = { 3, 4, 5, }; -+static const int mt7622_i2s_out_mclk_bclk_ws_funcs[] = { 0, 0, 0, }; -+static const int mt7622_i2s1_out_data_pins[] = { 2, }; -+static const int mt7622_i2s1_out_data_funcs[] = { 0, }; -+static const int mt7622_i2s2_out_data_pins[] = { 19, }; -+static const int mt7622_i2s2_out_data_funcs[] = { 0, }; -+static const int mt7622_i2s3_out_data_pins[] = { 20, }; -+static const int mt7622_i2s3_out_data_funcs[] = { 0, }; -+static const int mt7622_i2s4_out_data_pins[] = { 21, }; -+static const int mt7622_i2s4_out_data_funcs[] = { 0, }; - - /* IR */ --static int mt7622_ir_0_tx_pins[] = { 16, }; --static int mt7622_ir_0_tx_funcs[] = { 4, }; --static int mt7622_ir_1_tx_pins[] = { 59, }; --static int mt7622_ir_1_tx_funcs[] = { 5, }; --static int mt7622_ir_2_tx_pins[] = { 99, }; --static int mt7622_ir_2_tx_funcs[] = { 3, }; --static int mt7622_ir_0_rx_pins[] = { 17, }; --static int mt7622_ir_0_rx_funcs[] = { 4, }; --static int mt7622_ir_1_rx_pins[] = { 60, }; --static int mt7622_ir_1_rx_funcs[] = { 5, }; --static int mt7622_ir_2_rx_pins[] = { 100, }; --static int mt7622_ir_2_rx_funcs[] = { 3, }; -+static const int mt7622_ir_0_tx_pins[] = { 16, }; -+static const int mt7622_ir_0_tx_funcs[] = { 4, }; -+static const int mt7622_ir_1_tx_pins[] = { 59, }; -+static const int mt7622_ir_1_tx_funcs[] = { 5, }; -+static const int mt7622_ir_2_tx_pins[] = { 99, }; -+static const int mt7622_ir_2_tx_funcs[] = { 3, }; -+static const int mt7622_ir_0_rx_pins[] = { 17, }; -+static const int mt7622_ir_0_rx_funcs[] = { 4, }; -+static const int mt7622_ir_1_rx_pins[] = { 60, }; -+static const int mt7622_ir_1_rx_funcs[] = { 5, }; -+static const int mt7622_ir_2_rx_pins[] = { 100, }; -+static const int mt7622_ir_2_rx_funcs[] = { 3, }; - - /* MDIO */ --static int mt7622_mdc_mdio_pins[] = { 23, 24, }; --static int mt7622_mdc_mdio_funcs[] = { 0, 0, }; -+static const int mt7622_mdc_mdio_pins[] = { 23, 24, }; -+static const int mt7622_mdc_mdio_funcs[] = { 0, 0, }; - - /* PCIE */ --static int mt7622_pcie0_0_waken_pins[] = { 14, }; --static int mt7622_pcie0_0_waken_funcs[] = { 2, }; --static int mt7622_pcie0_0_clkreq_pins[] = { 15, }; --static int mt7622_pcie0_0_clkreq_funcs[] = { 2, }; --static int mt7622_pcie0_1_waken_pins[] = { 79, }; --static int mt7622_pcie0_1_waken_funcs[] = { 4, }; --static int mt7622_pcie0_1_clkreq_pins[] = { 80, }; --static int mt7622_pcie0_1_clkreq_funcs[] = { 4, }; --static int mt7622_pcie1_0_waken_pins[] = { 14, }; --static int mt7622_pcie1_0_waken_funcs[] = { 3, }; --static int mt7622_pcie1_0_clkreq_pins[] = { 15, }; --static int mt7622_pcie1_0_clkreq_funcs[] = { 3, }; -- --static int mt7622_pcie0_pad_perst_pins[] = { 83, }; --static int mt7622_pcie0_pad_perst_funcs[] = { 0, }; --static int mt7622_pcie1_pad_perst_pins[] = { 84, }; --static int mt7622_pcie1_pad_perst_funcs[] = { 0, }; -+static const int mt7622_pcie0_0_waken_pins[] = { 14, }; -+static const int mt7622_pcie0_0_waken_funcs[] = { 2, }; -+static const int mt7622_pcie0_0_clkreq_pins[] = { 15, }; -+static const int mt7622_pcie0_0_clkreq_funcs[] = { 2, }; -+static const int mt7622_pcie0_1_waken_pins[] = { 79, }; -+static const int mt7622_pcie0_1_waken_funcs[] = { 4, }; -+static const int mt7622_pcie0_1_clkreq_pins[] = { 80, }; -+static const int mt7622_pcie0_1_clkreq_funcs[] = { 4, }; -+static const int mt7622_pcie1_0_waken_pins[] = { 14, }; -+static const int mt7622_pcie1_0_waken_funcs[] = { 3, }; -+static const int mt7622_pcie1_0_clkreq_pins[] = { 15, }; -+static const int mt7622_pcie1_0_clkreq_funcs[] = { 3, }; -+ -+static const int mt7622_pcie0_pad_perst_pins[] = { 83, }; -+static const int mt7622_pcie0_pad_perst_funcs[] = { 0, }; -+static const int mt7622_pcie1_pad_perst_pins[] = { 84, }; -+static const int mt7622_pcie1_pad_perst_funcs[] = { 0, }; - - /* PMIC bus */ --static int mt7622_pmic_bus_pins[] = { 71, 72, }; --static int mt7622_pmic_bus_funcs[] = { 0, 0, }; -+static const int mt7622_pmic_bus_pins[] = { 71, 72, }; -+static const int mt7622_pmic_bus_funcs[] = { 0, 0, }; - - /* Parallel NAND */ --static int mt7622_pnand_pins[] = { 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, -- 48, 49, 50, }; --static int mt7622_pnand_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0, }; -+static const int mt7622_pnand_pins[] = { -+ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, }; -+static const int mt7622_pnand_funcs[] = { -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - - /* PWM */ --static int mt7622_pwm_ch1_0_pins[] = { 51, }; --static int mt7622_pwm_ch1_0_funcs[] = { 3, }; --static int mt7622_pwm_ch1_1_pins[] = { 73, }; --static int mt7622_pwm_ch1_1_funcs[] = { 4, }; --static int mt7622_pwm_ch1_2_pins[] = { 95, }; --static int mt7622_pwm_ch1_2_funcs[] = { 0, }; --static int mt7622_pwm_ch2_0_pins[] = { 52, }; --static int mt7622_pwm_ch2_0_funcs[] = { 3, }; --static int mt7622_pwm_ch2_1_pins[] = { 74, }; --static int mt7622_pwm_ch2_1_funcs[] = { 4, }; --static int mt7622_pwm_ch2_2_pins[] = { 96, }; --static int mt7622_pwm_ch2_2_funcs[] = { 0, }; --static int mt7622_pwm_ch3_0_pins[] = { 53, }; --static int mt7622_pwm_ch3_0_funcs[] = { 3, }; --static int mt7622_pwm_ch3_1_pins[] = { 75, }; --static int mt7622_pwm_ch3_1_funcs[] = { 4, }; --static int mt7622_pwm_ch3_2_pins[] = { 97, }; --static int mt7622_pwm_ch3_2_funcs[] = { 0, }; --static int mt7622_pwm_ch4_0_pins[] = { 54, }; --static int mt7622_pwm_ch4_0_funcs[] = { 3, }; --static int mt7622_pwm_ch4_1_pins[] = { 67, }; --static int mt7622_pwm_ch4_1_funcs[] = { 3, }; --static int mt7622_pwm_ch4_2_pins[] = { 76, }; --static int mt7622_pwm_ch4_2_funcs[] = { 4, }; --static int mt7622_pwm_ch4_3_pins[] = { 98, }; --static int mt7622_pwm_ch4_3_funcs[] = { 0, }; --static int mt7622_pwm_ch5_0_pins[] = { 68, }; --static int mt7622_pwm_ch5_0_funcs[] = { 3, }; --static int mt7622_pwm_ch5_1_pins[] = { 77, }; --static int mt7622_pwm_ch5_1_funcs[] = { 4, }; --static int mt7622_pwm_ch5_2_pins[] = { 99, }; --static int mt7622_pwm_ch5_2_funcs[] = { 0, }; --static int mt7622_pwm_ch6_0_pins[] = { 69, }; --static int mt7622_pwm_ch6_0_funcs[] = { 3, }; --static int mt7622_pwm_ch6_1_pins[] = { 78, }; --static int mt7622_pwm_ch6_1_funcs[] = { 4, }; --static int mt7622_pwm_ch6_2_pins[] = { 81, }; --static int mt7622_pwm_ch6_2_funcs[] = { 4, }; --static int mt7622_pwm_ch6_3_pins[] = { 100, }; --static int mt7622_pwm_ch6_3_funcs[] = { 0, }; --static int mt7622_pwm_ch7_0_pins[] = { 70, }; --static int mt7622_pwm_ch7_0_funcs[] = { 3, }; --static int mt7622_pwm_ch7_1_pins[] = { 82, }; --static int mt7622_pwm_ch7_1_funcs[] = { 4, }; --static int mt7622_pwm_ch7_2_pins[] = { 101, }; --static int mt7622_pwm_ch7_2_funcs[] = { 0, }; -+static const int mt7622_pwm_ch1_0_pins[] = { 51, }; -+static const int mt7622_pwm_ch1_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch1_1_pins[] = { 73, }; -+static const int mt7622_pwm_ch1_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch1_2_pins[] = { 95, }; -+static const int mt7622_pwm_ch1_2_funcs[] = { 0, }; -+static const int mt7622_pwm_ch2_0_pins[] = { 52, }; -+static const int mt7622_pwm_ch2_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch2_1_pins[] = { 74, }; -+static const int mt7622_pwm_ch2_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch2_2_pins[] = { 96, }; -+static const int mt7622_pwm_ch2_2_funcs[] = { 0, }; -+static const int mt7622_pwm_ch3_0_pins[] = { 53, }; -+static const int mt7622_pwm_ch3_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch3_1_pins[] = { 75, }; -+static const int mt7622_pwm_ch3_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch3_2_pins[] = { 97, }; -+static const int mt7622_pwm_ch3_2_funcs[] = { 0, }; -+static const int mt7622_pwm_ch4_0_pins[] = { 54, }; -+static const int mt7622_pwm_ch4_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch4_1_pins[] = { 67, }; -+static const int mt7622_pwm_ch4_1_funcs[] = { 3, }; -+static const int mt7622_pwm_ch4_2_pins[] = { 76, }; -+static const int mt7622_pwm_ch4_2_funcs[] = { 4, }; -+static const int mt7622_pwm_ch4_3_pins[] = { 98, }; -+static const int mt7622_pwm_ch4_3_funcs[] = { 0, }; -+static const int mt7622_pwm_ch5_0_pins[] = { 68, }; -+static const int mt7622_pwm_ch5_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch5_1_pins[] = { 77, }; -+static const int mt7622_pwm_ch5_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch5_2_pins[] = { 99, }; -+static const int mt7622_pwm_ch5_2_funcs[] = { 0, }; -+static const int mt7622_pwm_ch6_0_pins[] = { 69, }; -+static const int mt7622_pwm_ch6_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch6_1_pins[] = { 78, }; -+static const int mt7622_pwm_ch6_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch6_2_pins[] = { 81, }; -+static const int mt7622_pwm_ch6_2_funcs[] = { 4, }; -+static const int mt7622_pwm_ch6_3_pins[] = { 100, }; -+static const int mt7622_pwm_ch6_3_funcs[] = { 0, }; -+static const int mt7622_pwm_ch7_0_pins[] = { 70, }; -+static const int mt7622_pwm_ch7_0_funcs[] = { 3, }; -+static const int mt7622_pwm_ch7_1_pins[] = { 82, }; -+static const int mt7622_pwm_ch7_1_funcs[] = { 4, }; -+static const int mt7622_pwm_ch7_2_pins[] = { 101, }; -+static const int mt7622_pwm_ch7_2_funcs[] = { 0, }; - - /* SD */ --static int mt7622_sd_0_pins[] = { 16, 17, 18, 19, 20, 21, }; --static int mt7622_sd_0_funcs[] = { 2, 2, 2, 2, 2, 2, }; --static int mt7622_sd_1_pins[] = { 25, 26, 27, 28, 29, 30, }; --static int mt7622_sd_1_funcs[] = { 2, 2, 2, 2, 2, 2, }; -+static const int mt7622_sd_0_pins[] = { 16, 17, 18, 19, 20, 21, }; -+static const int mt7622_sd_0_funcs[] = { 2, 2, 2, 2, 2, 2, }; -+static const int mt7622_sd_1_pins[] = { 25, 26, 27, 28, 29, 30, }; -+static const int mt7622_sd_1_funcs[] = { 2, 2, 2, 2, 2, 2, }; - - /* Serial NAND */ --static int mt7622_snfi_pins[] = { 8, 9, 10, 11, 12, 13, }; --static int mt7622_snfi_funcs[] = { 2, 2, 2, 2, 2, 2, }; -+static const int mt7622_snfi_pins[] = { 8, 9, 10, 11, 12, 13, }; -+static const int mt7622_snfi_funcs[] = { 2, 2, 2, 2, 2, 2, }; - - /* SPI NOR */ --static int mt7622_spi_pins[] = { 8, 9, 10, 11, 12, 13 }; --static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, }; -+static const int mt7622_spi_pins[] = { 8, 9, 10, 11, 12, 13 }; -+static const int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, }; - - /* SPIC */ --static int mt7622_spic0_0_pins[] = { 63, 64, 65, 66, }; --static int mt7622_spic0_0_funcs[] = { 4, 4, 4, 4, }; --static int mt7622_spic0_1_pins[] = { 79, 80, 81, 82, }; --static int mt7622_spic0_1_funcs[] = { 3, 3, 3, 3, }; --static int mt7622_spic1_0_pins[] = { 67, 68, 69, 70, }; --static int mt7622_spic1_0_funcs[] = { 4, 4, 4, 4, }; --static int mt7622_spic1_1_pins[] = { 73, 74, 75, 76, }; --static int mt7622_spic1_1_funcs[] = { 0, 0, 0, 0, }; --static int mt7622_spic2_0_pins[] = { 10, 11, 12, 13, }; --static int mt7622_spic2_0_funcs[] = { 0, 0, 0, 0, }; --static int mt7622_spic2_0_wp_hold_pins[] = { 8, 9, }; --static int mt7622_spic2_0_wp_hold_funcs[] = { 0, 0, }; -+static const int mt7622_spic0_0_pins[] = { 63, 64, 65, 66, }; -+static const int mt7622_spic0_0_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7622_spic0_1_pins[] = { 79, 80, 81, 82, }; -+static const int mt7622_spic0_1_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7622_spic1_0_pins[] = { 67, 68, 69, 70, }; -+static const int mt7622_spic1_0_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7622_spic1_1_pins[] = { 73, 74, 75, 76, }; -+static const int mt7622_spic1_1_funcs[] = { 0, 0, 0, 0, }; -+static const int mt7622_spic2_0_pins[] = { 10, 11, 12, 13, }; -+static const int mt7622_spic2_0_funcs[] = { 0, 0, 0, 0, }; -+static const int mt7622_spic2_0_wp_hold_pins[] = { 8, 9, }; -+static const int mt7622_spic2_0_wp_hold_funcs[] = { 0, 0, }; - - /* TDM */ --static int mt7622_tdm_0_out_mclk_bclk_ws_pins[] = { 8, 9, 10, }; --static int mt7622_tdm_0_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; --static int mt7622_tdm_0_in_mclk_bclk_ws_pins[] = { 11, 12, 13, }; --static int mt7622_tdm_0_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; --static int mt7622_tdm_0_out_data_pins[] = { 20, }; --static int mt7622_tdm_0_out_data_funcs[] = { 3, }; --static int mt7622_tdm_0_in_data_pins[] = { 21, }; --static int mt7622_tdm_0_in_data_funcs[] = { 3, }; --static int mt7622_tdm_1_out_mclk_bclk_ws_pins[] = { 57, 58, 59, }; --static int mt7622_tdm_1_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; --static int mt7622_tdm_1_in_mclk_bclk_ws_pins[] = { 60, 61, 62, }; --static int mt7622_tdm_1_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; --static int mt7622_tdm_1_out_data_pins[] = { 55, }; --static int mt7622_tdm_1_out_data_funcs[] = { 3, }; --static int mt7622_tdm_1_in_data_pins[] = { 56, }; --static int mt7622_tdm_1_in_data_funcs[] = { 3, }; -+static const int mt7622_tdm_0_out_mclk_bclk_ws_pins[] = { 8, 9, 10, }; -+static const int mt7622_tdm_0_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; -+static const int mt7622_tdm_0_in_mclk_bclk_ws_pins[] = { 11, 12, 13, }; -+static const int mt7622_tdm_0_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; -+static const int mt7622_tdm_0_out_data_pins[] = { 20, }; -+static const int mt7622_tdm_0_out_data_funcs[] = { 3, }; -+static const int mt7622_tdm_0_in_data_pins[] = { 21, }; -+static const int mt7622_tdm_0_in_data_funcs[] = { 3, }; -+static const int mt7622_tdm_1_out_mclk_bclk_ws_pins[] = { 57, 58, 59, }; -+static const int mt7622_tdm_1_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; -+static const int mt7622_tdm_1_in_mclk_bclk_ws_pins[] = { 60, 61, 62, }; -+static const int mt7622_tdm_1_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, }; -+static const int mt7622_tdm_1_out_data_pins[] = { 55, }; -+static const int mt7622_tdm_1_out_data_funcs[] = { 3, }; -+static const int mt7622_tdm_1_in_data_pins[] = { 56, }; -+static const int mt7622_tdm_1_in_data_funcs[] = { 3, }; - - /* UART */ --static int mt7622_uart0_0_tx_rx_pins[] = { 6, 7, }; --static int mt7622_uart0_0_tx_rx_funcs[] = { 0, 0, }; --static int mt7622_uart1_0_tx_rx_pins[] = { 55, 56, }; --static int mt7622_uart1_0_tx_rx_funcs[] = { 2, 2, }; --static int mt7622_uart1_0_rts_cts_pins[] = { 57, 58, }; --static int mt7622_uart1_0_rts_cts_funcs[] = { 2, 2, }; --static int mt7622_uart1_1_tx_rx_pins[] = { 73, 74, }; --static int mt7622_uart1_1_tx_rx_funcs[] = { 2, 2, }; --static int mt7622_uart1_1_rts_cts_pins[] = { 75, 76, }; --static int mt7622_uart1_1_rts_cts_funcs[] = { 2, 2, }; --static int mt7622_uart2_0_tx_rx_pins[] = { 3, 4, }; --static int mt7622_uart2_0_tx_rx_funcs[] = { 2, 2, }; --static int mt7622_uart2_0_rts_cts_pins[] = { 1, 2, }; --static int mt7622_uart2_0_rts_cts_funcs[] = { 2, 2, }; --static int mt7622_uart2_1_tx_rx_pins[] = { 51, 52, }; --static int mt7622_uart2_1_tx_rx_funcs[] = { 0, 0, }; --static int mt7622_uart2_1_rts_cts_pins[] = { 53, 54, }; --static int mt7622_uart2_1_rts_cts_funcs[] = { 0, 0, }; --static int mt7622_uart2_2_tx_rx_pins[] = { 59, 60, }; --static int mt7622_uart2_2_tx_rx_funcs[] = { 4, 4, }; --static int mt7622_uart2_2_rts_cts_pins[] = { 61, 62, }; --static int mt7622_uart2_2_rts_cts_funcs[] = { 4, 4, }; --static int mt7622_uart2_3_tx_rx_pins[] = { 95, 96, }; --static int mt7622_uart2_3_tx_rx_funcs[] = { 3, 3, }; --static int mt7622_uart3_0_tx_rx_pins[] = { 57, 58, }; --static int mt7622_uart3_0_tx_rx_funcs[] = { 5, 5, }; --static int mt7622_uart3_1_tx_rx_pins[] = { 81, 82, }; --static int mt7622_uart3_1_tx_rx_funcs[] = { 0, 0, }; --static int mt7622_uart3_1_rts_cts_pins[] = { 79, 80, }; --static int mt7622_uart3_1_rts_cts_funcs[] = { 0, 0, }; --static int mt7622_uart4_0_tx_rx_pins[] = { 61, 62, }; --static int mt7622_uart4_0_tx_rx_funcs[] = { 5, 5, }; --static int mt7622_uart4_1_tx_rx_pins[] = { 91, 92, }; --static int mt7622_uart4_1_tx_rx_funcs[] = { 0, 0, }; --static int mt7622_uart4_1_rts_cts_pins[] = { 93, 94 }; --static int mt7622_uart4_1_rts_cts_funcs[] = { 0, 0, }; --static int mt7622_uart4_2_tx_rx_pins[] = { 97, 98, }; --static int mt7622_uart4_2_tx_rx_funcs[] = { 2, 2, }; --static int mt7622_uart4_2_rts_cts_pins[] = { 95, 96 }; --static int mt7622_uart4_2_rts_cts_funcs[] = { 2, 2, }; -+static const int mt7622_uart0_0_tx_rx_pins[] = { 6, 7, }; -+static const int mt7622_uart0_0_tx_rx_funcs[] = { 0, 0, }; -+static const int mt7622_uart1_0_tx_rx_pins[] = { 55, 56, }; -+static const int mt7622_uart1_0_tx_rx_funcs[] = { 2, 2, }; -+static const int mt7622_uart1_0_rts_cts_pins[] = { 57, 58, }; -+static const int mt7622_uart1_0_rts_cts_funcs[] = { 2, 2, }; -+static const int mt7622_uart1_1_tx_rx_pins[] = { 73, 74, }; -+static const int mt7622_uart1_1_tx_rx_funcs[] = { 2, 2, }; -+static const int mt7622_uart1_1_rts_cts_pins[] = { 75, 76, }; -+static const int mt7622_uart1_1_rts_cts_funcs[] = { 2, 2, }; -+static const int mt7622_uart2_0_tx_rx_pins[] = { 3, 4, }; -+static const int mt7622_uart2_0_tx_rx_funcs[] = { 2, 2, }; -+static const int mt7622_uart2_0_rts_cts_pins[] = { 1, 2, }; -+static const int mt7622_uart2_0_rts_cts_funcs[] = { 2, 2, }; -+static const int mt7622_uart2_1_tx_rx_pins[] = { 51, 52, }; -+static const int mt7622_uart2_1_tx_rx_funcs[] = { 0, 0, }; -+static const int mt7622_uart2_1_rts_cts_pins[] = { 53, 54, }; -+static const int mt7622_uart2_1_rts_cts_funcs[] = { 0, 0, }; -+static const int mt7622_uart2_2_tx_rx_pins[] = { 59, 60, }; -+static const int mt7622_uart2_2_tx_rx_funcs[] = { 4, 4, }; -+static const int mt7622_uart2_2_rts_cts_pins[] = { 61, 62, }; -+static const int mt7622_uart2_2_rts_cts_funcs[] = { 4, 4, }; -+static const int mt7622_uart2_3_tx_rx_pins[] = { 95, 96, }; -+static const int mt7622_uart2_3_tx_rx_funcs[] = { 3, 3, }; -+static const int mt7622_uart3_0_tx_rx_pins[] = { 57, 58, }; -+static const int mt7622_uart3_0_tx_rx_funcs[] = { 5, 5, }; -+static const int mt7622_uart3_1_tx_rx_pins[] = { 81, 82, }; -+static const int mt7622_uart3_1_tx_rx_funcs[] = { 0, 0, }; -+static const int mt7622_uart3_1_rts_cts_pins[] = { 79, 80, }; -+static const int mt7622_uart3_1_rts_cts_funcs[] = { 0, 0, }; -+static const int mt7622_uart4_0_tx_rx_pins[] = { 61, 62, }; -+static const int mt7622_uart4_0_tx_rx_funcs[] = { 5, 5, }; -+static const int mt7622_uart4_1_tx_rx_pins[] = { 91, 92, }; -+static const int mt7622_uart4_1_tx_rx_funcs[] = { 0, 0, }; -+static const int mt7622_uart4_1_rts_cts_pins[] = { 93, 94 }; -+static const int mt7622_uart4_1_rts_cts_funcs[] = { 0, 0, }; -+static const int mt7622_uart4_2_tx_rx_pins[] = { 97, 98, }; -+static const int mt7622_uart4_2_tx_rx_funcs[] = { 2, 2, }; -+static const int mt7622_uart4_2_rts_cts_pins[] = { 95, 96 }; -+static const int mt7622_uart4_2_rts_cts_funcs[] = { 2, 2, }; - - /* Watchdog */ --static int mt7622_watchdog_pins[] = { 78, }; --static int mt7622_watchdog_funcs[] = { 0, }; -+static const int mt7622_watchdog_pins[] = { 78, }; -+static const int mt7622_watchdog_funcs[] = { 0, }; - - /* WLAN LED */ --static int mt7622_wled_pins[] = { 85, }; --static int mt7622_wled_funcs[] = { 0, }; -+static const int mt7622_wled_pins[] = { 85, }; -+static const int mt7622_wled_funcs[] = { 0, }; - - static const struct mtk_group_desc mt7622_groups[] = { - PINCTRL_PIN_GROUP("emmc", mt7622_emmc), -@@ -719,7 +721,7 @@ static const struct mtk_function_desc mt - {"watchdog", mt7622_wdt_groups, ARRAY_SIZE(mt7622_wdt_groups)}, - }; - --static struct mtk_pinctrl_soc mt7622_data = { -+static const struct mtk_pinctrl_soc mt7622_data = { - .name = "mt7622_pinctrl", - .reg_cal = mt7622_reg_cals, - .pins = mt7622_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt7623.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c -@@ -692,377 +692,377 @@ static const struct mtk_pin_desc mt7623_ - */ - - /* AUDIO EXT CLK */ --static int mt7623_aud_ext_clk0_pins[] = { 208, }; --static int mt7623_aud_ext_clk0_funcs[] = { 1, }; --static int mt7623_aud_ext_clk1_pins[] = { 209, }; --static int mt7623_aud_ext_clk1_funcs[] = { 1, }; -+static const int mt7623_aud_ext_clk0_pins[] = { 208, }; -+static const int mt7623_aud_ext_clk0_funcs[] = { 1, }; -+static const int mt7623_aud_ext_clk1_pins[] = { 209, }; -+static const int mt7623_aud_ext_clk1_funcs[] = { 1, }; - - /* DISP PWM */ --static int mt7623_disp_pwm_0_pins[] = { 72, }; --static int mt7623_disp_pwm_0_funcs[] = { 5, }; --static int mt7623_disp_pwm_1_pins[] = { 203, }; --static int mt7623_disp_pwm_1_funcs[] = { 2, }; --static int mt7623_disp_pwm_2_pins[] = { 208, }; --static int mt7623_disp_pwm_2_funcs[] = { 5, }; -+static const int mt7623_disp_pwm_0_pins[] = { 72, }; -+static const int mt7623_disp_pwm_0_funcs[] = { 5, }; -+static const int mt7623_disp_pwm_1_pins[] = { 203, }; -+static const int mt7623_disp_pwm_1_funcs[] = { 2, }; -+static const int mt7623_disp_pwm_2_pins[] = { 208, }; -+static const int mt7623_disp_pwm_2_funcs[] = { 5, }; - - /* ESW */ --static int mt7623_esw_int_pins[] = { 273, }; --static int mt7623_esw_int_funcs[] = { 1, }; --static int mt7623_esw_rst_pins[] = { 277, }; --static int mt7623_esw_rst_funcs[] = { 1, }; -+static const int mt7623_esw_int_pins[] = { 273, }; -+static const int mt7623_esw_int_funcs[] = { 1, }; -+static const int mt7623_esw_rst_pins[] = { 277, }; -+static const int mt7623_esw_rst_funcs[] = { 1, }; - - /* EPHY */ --static int mt7623_ephy_pins[] = { 262, 263, 264, 265, 266, 267, 268, -- 269, 270, 271, 272, 274, }; --static int mt7623_ephy_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_ephy_pins[] = { 262, 263, 264, 265, 266, 267, 268, -+ 269, 270, 271, 272, 274, }; -+static const int mt7623_ephy_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - /* EXT_SDIO */ --static int mt7623_ext_sdio_pins[] = { 236, 237, 238, 239, 240, 241, }; --static int mt7623_ext_sdio_funcs[] = { 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_ext_sdio_pins[] = { 236, 237, 238, 239, 240, 241, }; -+static const int mt7623_ext_sdio_funcs[] = { 1, 1, 1, 1, 1, 1, }; - - /* HDMI RX */ --static int mt7623_hdmi_rx_pins[] = { 247, 248, }; --static int mt7623_hdmi_rx_funcs[] = { 1, 1 }; --static int mt7623_hdmi_rx_i2c_pins[] = { 244, 245, }; --static int mt7623_hdmi_rx_i2c_funcs[] = { 1, 1 }; -+static const int mt7623_hdmi_rx_pins[] = { 247, 248, }; -+static const int mt7623_hdmi_rx_funcs[] = { 1, 1 }; -+static const int mt7623_hdmi_rx_i2c_pins[] = { 244, 245, }; -+static const int mt7623_hdmi_rx_i2c_funcs[] = { 1, 1 }; - - /* HDMI TX */ --static int mt7623_hdmi_cec_pins[] = { 122, }; --static int mt7623_hdmi_cec_funcs[] = { 1, }; --static int mt7623_hdmi_htplg_pins[] = { 123, }; --static int mt7623_hdmi_htplg_funcs[] = { 1, }; --static int mt7623_hdmi_i2c_pins[] = { 124, 125, }; --static int mt7623_hdmi_i2c_funcs[] = { 1, 1 }; -+static const int mt7623_hdmi_cec_pins[] = { 122, }; -+static const int mt7623_hdmi_cec_funcs[] = { 1, }; -+static const int mt7623_hdmi_htplg_pins[] = { 123, }; -+static const int mt7623_hdmi_htplg_funcs[] = { 1, }; -+static const int mt7623_hdmi_i2c_pins[] = { 124, 125, }; -+static const int mt7623_hdmi_i2c_funcs[] = { 1, 1 }; - - /* I2C */ --static int mt7623_i2c0_pins[] = { 75, 76, }; --static int mt7623_i2c0_funcs[] = { 1, 1, }; --static int mt7623_i2c1_0_pins[] = { 57, 58, }; --static int mt7623_i2c1_0_funcs[] = { 1, 1, }; --static int mt7623_i2c1_1_pins[] = { 242, 243, }; --static int mt7623_i2c1_1_funcs[] = { 4, 4, }; --static int mt7623_i2c1_2_pins[] = { 85, 86, }; --static int mt7623_i2c1_2_funcs[] = { 3, 3, }; --static int mt7623_i2c1_3_pins[] = { 105, 106, }; --static int mt7623_i2c1_3_funcs[] = { 3, 3, }; --static int mt7623_i2c1_4_pins[] = { 124, 125, }; --static int mt7623_i2c1_4_funcs[] = { 4, 4, }; --static int mt7623_i2c2_0_pins[] = { 77, 78, }; --static int mt7623_i2c2_0_funcs[] = { 1, 1, }; --static int mt7623_i2c2_1_pins[] = { 89, 90, }; --static int mt7623_i2c2_1_funcs[] = { 3, 3, }; --static int mt7623_i2c2_2_pins[] = { 109, 110, }; --static int mt7623_i2c2_2_funcs[] = { 3, 3, }; --static int mt7623_i2c2_3_pins[] = { 122, 123, }; --static int mt7623_i2c2_3_funcs[] = { 4, 4, }; -+static const int mt7623_i2c0_pins[] = { 75, 76, }; -+static const int mt7623_i2c0_funcs[] = { 1, 1, }; -+static const int mt7623_i2c1_0_pins[] = { 57, 58, }; -+static const int mt7623_i2c1_0_funcs[] = { 1, 1, }; -+static const int mt7623_i2c1_1_pins[] = { 242, 243, }; -+static const int mt7623_i2c1_1_funcs[] = { 4, 4, }; -+static const int mt7623_i2c1_2_pins[] = { 85, 86, }; -+static const int mt7623_i2c1_2_funcs[] = { 3, 3, }; -+static const int mt7623_i2c1_3_pins[] = { 105, 106, }; -+static const int mt7623_i2c1_3_funcs[] = { 3, 3, }; -+static const int mt7623_i2c1_4_pins[] = { 124, 125, }; -+static const int mt7623_i2c1_4_funcs[] = { 4, 4, }; -+static const int mt7623_i2c2_0_pins[] = { 77, 78, }; -+static const int mt7623_i2c2_0_funcs[] = { 1, 1, }; -+static const int mt7623_i2c2_1_pins[] = { 89, 90, }; -+static const int mt7623_i2c2_1_funcs[] = { 3, 3, }; -+static const int mt7623_i2c2_2_pins[] = { 109, 110, }; -+static const int mt7623_i2c2_2_funcs[] = { 3, 3, }; -+static const int mt7623_i2c2_3_pins[] = { 122, 123, }; -+static const int mt7623_i2c2_3_funcs[] = { 4, 4, }; - - /* I2S */ --static int mt7623_i2s0_pins[] = { 49, 72, 73, 74, 126, }; --static int mt7623_i2s0_funcs[] = { 1, 1, 1, 1, 1, }; --static int mt7623_i2s1_pins[] = { 33, 34, 35, 36, 37, }; --static int mt7623_i2s1_funcs[] = { 1, 1, 1, 1, 1, }; --static int mt7623_i2s2_bclk_lrclk_mclk_pins[] = { 50, 52, 188, }; --static int mt7623_i2s2_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, }; --static int mt7623_i2s2_data_in_pins[] = { 51, }; --static int mt7623_i2s2_data_in_funcs[] = { 1, }; --static int mt7623_i2s2_data_0_pins[] = { 203, }; --static int mt7623_i2s2_data_0_funcs[] = { 9, }; --static int mt7623_i2s2_data_1_pins[] = { 38, }; --static int mt7623_i2s2_data_1_funcs[] = { 4, }; --static int mt7623_i2s3_bclk_lrclk_mclk_pins[] = { 191, 192, 193, }; --static int mt7623_i2s3_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, }; --static int mt7623_i2s3_data_in_pins[] = { 190, }; --static int mt7623_i2s3_data_in_funcs[] = { 1, }; --static int mt7623_i2s3_data_0_pins[] = { 204, }; --static int mt7623_i2s3_data_0_funcs[] = { 9, }; --static int mt7623_i2s3_data_1_pins[] = { 2, }; --static int mt7623_i2s3_data_1_funcs[] = { 0, }; --static int mt7623_i2s4_pins[] = { 194, 195, 196, 197, 198, }; --static int mt7623_i2s4_funcs[] = { 1, 1, 1, 1, 1, }; --static int mt7623_i2s5_pins[] = { 16, 17, 30, 31, 32, }; --static int mt7623_i2s5_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7623_i2s0_pins[] = { 49, 72, 73, 74, 126, }; -+static const int mt7623_i2s0_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7623_i2s1_pins[] = { 33, 34, 35, 36, 37, }; -+static const int mt7623_i2s1_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7623_i2s2_bclk_lrclk_mclk_pins[] = { 50, 52, 188, }; -+static const int mt7623_i2s2_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, }; -+static const int mt7623_i2s2_data_in_pins[] = { 51, }; -+static const int mt7623_i2s2_data_in_funcs[] = { 1, }; -+static const int mt7623_i2s2_data_0_pins[] = { 203, }; -+static const int mt7623_i2s2_data_0_funcs[] = { 9, }; -+static const int mt7623_i2s2_data_1_pins[] = { 38, }; -+static const int mt7623_i2s2_data_1_funcs[] = { 4, }; -+static const int mt7623_i2s3_bclk_lrclk_mclk_pins[] = { 191, 192, 193, }; -+static const int mt7623_i2s3_bclk_lrclk_mclk_funcs[] = { 1, 1, 1, }; -+static const int mt7623_i2s3_data_in_pins[] = { 190, }; -+static const int mt7623_i2s3_data_in_funcs[] = { 1, }; -+static const int mt7623_i2s3_data_0_pins[] = { 204, }; -+static const int mt7623_i2s3_data_0_funcs[] = { 9, }; -+static const int mt7623_i2s3_data_1_pins[] = { 2, }; -+static const int mt7623_i2s3_data_1_funcs[] = { 0, }; -+static const int mt7623_i2s4_pins[] = { 194, 195, 196, 197, 198, }; -+static const int mt7623_i2s4_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7623_i2s5_pins[] = { 16, 17, 30, 31, 32, }; -+static const int mt7623_i2s5_funcs[] = { 1, 1, 1, 1, 1, }; - - /* IR */ --static int mt7623_ir_pins[] = { 46, }; --static int mt7623_ir_funcs[] = { 1, }; -+static const int mt7623_ir_pins[] = { 46, }; -+static const int mt7623_ir_funcs[] = { 1, }; - - /* LCD */ --static int mt7623_mipi_tx_pins[] = { 91, 92, 93, 94, 95, 96, 97, 98, -- 99, 100, }; --static int mt7623_mipi_tx_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; --static int mt7623_dsi_te_pins[] = { 84, }; --static int mt7623_dsi_te_funcs[] = { 1, }; --static int mt7623_lcm_rst_pins[] = { 83, }; --static int mt7623_lcm_rst_funcs[] = { 1, }; -+static const int mt7623_mipi_tx_pins[] = { 91, 92, 93, 94, 95, 96, 97, 98, -+ 99, 100, }; -+static const int mt7623_mipi_tx_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_dsi_te_pins[] = { 84, }; -+static const int mt7623_dsi_te_funcs[] = { 1, }; -+static const int mt7623_lcm_rst_pins[] = { 83, }; -+static const int mt7623_lcm_rst_funcs[] = { 1, }; - - /* MDC/MDIO */ --static int mt7623_mdc_mdio_pins[] = { 275, 276, }; --static int mt7623_mdc_mdio_funcs[] = { 1, 1, }; -+static const int mt7623_mdc_mdio_pins[] = { 275, 276, }; -+static const int mt7623_mdc_mdio_funcs[] = { 1, 1, }; - - /* MSDC */ --static int mt7623_msdc0_pins[] = { 111, 112, 113, 114, 115, 116, 117, 118, -- 119, 120, 121, }; --static int mt7623_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; --static int mt7623_msdc1_pins[] = { 105, 106, 107, 108, 109, 110, }; --static int mt7623_msdc1_funcs[] = { 1, 1, 1, 1, 1, 1, }; --static int mt7623_msdc1_ins_pins[] = { 261, }; --static int mt7623_msdc1_ins_funcs[] = { 1, }; --static int mt7623_msdc1_wp_0_pins[] = { 29, }; --static int mt7623_msdc1_wp_0_funcs[] = { 1, }; --static int mt7623_msdc1_wp_1_pins[] = { 55, }; --static int mt7623_msdc1_wp_1_funcs[] = { 3, }; --static int mt7623_msdc1_wp_2_pins[] = { 209, }; --static int mt7623_msdc1_wp_2_funcs[] = { 2, }; --static int mt7623_msdc2_pins[] = { 85, 86, 87, 88, 89, 90, }; --static int mt7623_msdc2_funcs[] = { 1, 1, 1, 1, 1, 1, }; --static int mt7623_msdc3_pins[] = { 249, 250, 251, 252, 253, 254, 255, 256, -- 257, 258, 259, 260, }; --static int mt7623_msdc3_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_msdc0_pins[] = { 111, 112, 113, 114, 115, 116, 117, 118, -+ 119, 120, 121, }; -+static const int mt7623_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_msdc1_pins[] = { 105, 106, 107, 108, 109, 110, }; -+static const int mt7623_msdc1_funcs[] = { 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_msdc1_ins_pins[] = { 261, }; -+static const int mt7623_msdc1_ins_funcs[] = { 1, }; -+static const int mt7623_msdc1_wp_0_pins[] = { 29, }; -+static const int mt7623_msdc1_wp_0_funcs[] = { 1, }; -+static const int mt7623_msdc1_wp_1_pins[] = { 55, }; -+static const int mt7623_msdc1_wp_1_funcs[] = { 3, }; -+static const int mt7623_msdc1_wp_2_pins[] = { 209, }; -+static const int mt7623_msdc1_wp_2_funcs[] = { 2, }; -+static const int mt7623_msdc2_pins[] = { 85, 86, 87, 88, 89, 90, }; -+static const int mt7623_msdc2_funcs[] = { 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_msdc3_pins[] = { 249, 250, 251, 252, 253, 254, 255, 256, -+ 257, 258, 259, 260, }; -+static const int mt7623_msdc3_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - /* NAND */ --static int mt7623_nandc_pins[] = { 43, 47, 48, 111, 112, 113, 114, 115, -- 116, 117, 118, 119, 120, 121, }; --static int mt7623_nandc_funcs[] = { 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, -- 4, 4, }; --static int mt7623_nandc_ceb0_pins[] = { 45, }; --static int mt7623_nandc_ceb0_funcs[] = { 1, }; --static int mt7623_nandc_ceb1_pins[] = { 44, }; --static int mt7623_nandc_ceb1_funcs[] = { 1, }; -+static const int mt7623_nandc_pins[] = { 43, 47, 48, 111, 112, 113, 114, 115, -+ 116, 117, 118, 119, 120, 121, }; -+static const int mt7623_nandc_funcs[] = { 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, -+ 4, 4, }; -+static const int mt7623_nandc_ceb0_pins[] = { 45, }; -+static const int mt7623_nandc_ceb0_funcs[] = { 1, }; -+static const int mt7623_nandc_ceb1_pins[] = { 44, }; -+static const int mt7623_nandc_ceb1_funcs[] = { 1, }; - - /* RTC */ --static int mt7623_rtc_pins[] = { 10, }; --static int mt7623_rtc_funcs[] = { 1, }; -+static const int mt7623_rtc_pins[] = { 10, }; -+static const int mt7623_rtc_funcs[] = { 1, }; - - /* OTG */ --static int mt7623_otg_iddig0_0_pins[] = { 29, }; --static int mt7623_otg_iddig0_0_funcs[] = { 1, }; --static int mt7623_otg_iddig0_1_pins[] = { 44, }; --static int mt7623_otg_iddig0_1_funcs[] = { 2, }; --static int mt7623_otg_iddig0_2_pins[] = { 236, }; --static int mt7623_otg_iddig0_2_funcs[] = { 2, }; --static int mt7623_otg_iddig1_0_pins[] = { 27, }; --static int mt7623_otg_iddig1_0_funcs[] = { 2, }; --static int mt7623_otg_iddig1_1_pins[] = { 47, }; --static int mt7623_otg_iddig1_1_funcs[] = { 2, }; --static int mt7623_otg_iddig1_2_pins[] = { 238, }; --static int mt7623_otg_iddig1_2_funcs[] = { 2, }; --static int mt7623_otg_drv_vbus0_0_pins[] = { 28, }; --static int mt7623_otg_drv_vbus0_0_funcs[] = { 1, }; --static int mt7623_otg_drv_vbus0_1_pins[] = { 45, }; --static int mt7623_otg_drv_vbus0_1_funcs[] = { 2, }; --static int mt7623_otg_drv_vbus0_2_pins[] = { 237, }; --static int mt7623_otg_drv_vbus0_2_funcs[] = { 2, }; --static int mt7623_otg_drv_vbus1_0_pins[] = { 26, }; --static int mt7623_otg_drv_vbus1_0_funcs[] = { 2, }; --static int mt7623_otg_drv_vbus1_1_pins[] = { 48, }; --static int mt7623_otg_drv_vbus1_1_funcs[] = { 2, }; --static int mt7623_otg_drv_vbus1_2_pins[] = { 239, }; --static int mt7623_otg_drv_vbus1_2_funcs[] = { 2, }; -+static const int mt7623_otg_iddig0_0_pins[] = { 29, }; -+static const int mt7623_otg_iddig0_0_funcs[] = { 1, }; -+static const int mt7623_otg_iddig0_1_pins[] = { 44, }; -+static const int mt7623_otg_iddig0_1_funcs[] = { 2, }; -+static const int mt7623_otg_iddig0_2_pins[] = { 236, }; -+static const int mt7623_otg_iddig0_2_funcs[] = { 2, }; -+static const int mt7623_otg_iddig1_0_pins[] = { 27, }; -+static const int mt7623_otg_iddig1_0_funcs[] = { 2, }; -+static const int mt7623_otg_iddig1_1_pins[] = { 47, }; -+static const int mt7623_otg_iddig1_1_funcs[] = { 2, }; -+static const int mt7623_otg_iddig1_2_pins[] = { 238, }; -+static const int mt7623_otg_iddig1_2_funcs[] = { 2, }; -+static const int mt7623_otg_drv_vbus0_0_pins[] = { 28, }; -+static const int mt7623_otg_drv_vbus0_0_funcs[] = { 1, }; -+static const int mt7623_otg_drv_vbus0_1_pins[] = { 45, }; -+static const int mt7623_otg_drv_vbus0_1_funcs[] = { 2, }; -+static const int mt7623_otg_drv_vbus0_2_pins[] = { 237, }; -+static const int mt7623_otg_drv_vbus0_2_funcs[] = { 2, }; -+static const int mt7623_otg_drv_vbus1_0_pins[] = { 26, }; -+static const int mt7623_otg_drv_vbus1_0_funcs[] = { 2, }; -+static const int mt7623_otg_drv_vbus1_1_pins[] = { 48, }; -+static const int mt7623_otg_drv_vbus1_1_funcs[] = { 2, }; -+static const int mt7623_otg_drv_vbus1_2_pins[] = { 239, }; -+static const int mt7623_otg_drv_vbus1_2_funcs[] = { 2, }; - - /* PCIE */ --static int mt7623_pcie0_0_perst_pins[] = { 208, }; --static int mt7623_pcie0_0_perst_funcs[] = { 3, }; --static int mt7623_pcie0_1_perst_pins[] = { 22, }; --static int mt7623_pcie0_1_perst_funcs[] = { 2, }; --static int mt7623_pcie1_0_perst_pins[] = { 209, }; --static int mt7623_pcie1_0_perst_funcs[] = { 3, }; --static int mt7623_pcie1_1_perst_pins[] = { 23, }; --static int mt7623_pcie1_1_perst_funcs[] = { 2, }; --static int mt7623_pcie2_0_perst_pins[] = { 24, }; --static int mt7623_pcie2_0_perst_funcs[] = { 2, }; --static int mt7623_pcie2_1_perst_pins[] = { 29, }; --static int mt7623_pcie2_1_perst_funcs[] = { 6, }; --static int mt7623_pcie0_0_wake_pins[] = { 28, }; --static int mt7623_pcie0_0_wake_funcs[] = { 6, }; --static int mt7623_pcie0_1_wake_pins[] = { 251, }; --static int mt7623_pcie0_1_wake_funcs[] = { 6, }; --static int mt7623_pcie1_0_wake_pins[] = { 27, }; --static int mt7623_pcie1_0_wake_funcs[] = { 6, }; --static int mt7623_pcie1_1_wake_pins[] = { 253, }; --static int mt7623_pcie1_1_wake_funcs[] = { 6, }; --static int mt7623_pcie2_0_wake_pins[] = { 26, }; --static int mt7623_pcie2_0_wake_funcs[] = { 6, }; --static int mt7623_pcie2_1_wake_pins[] = { 255, }; --static int mt7623_pcie2_1_wake_funcs[] = { 6, }; --static int mt7623_pcie0_clkreq_pins[] = { 250, }; --static int mt7623_pcie0_clkreq_funcs[] = { 6, }; --static int mt7623_pcie1_clkreq_pins[] = { 252, }; --static int mt7623_pcie1_clkreq_funcs[] = { 6, }; --static int mt7623_pcie2_clkreq_pins[] = { 254, }; --static int mt7623_pcie2_clkreq_funcs[] = { 6, }; -+static const int mt7623_pcie0_0_perst_pins[] = { 208, }; -+static const int mt7623_pcie0_0_perst_funcs[] = { 3, }; -+static const int mt7623_pcie0_1_perst_pins[] = { 22, }; -+static const int mt7623_pcie0_1_perst_funcs[] = { 2, }; -+static const int mt7623_pcie1_0_perst_pins[] = { 209, }; -+static const int mt7623_pcie1_0_perst_funcs[] = { 3, }; -+static const int mt7623_pcie1_1_perst_pins[] = { 23, }; -+static const int mt7623_pcie1_1_perst_funcs[] = { 2, }; -+static const int mt7623_pcie2_0_perst_pins[] = { 24, }; -+static const int mt7623_pcie2_0_perst_funcs[] = { 2, }; -+static const int mt7623_pcie2_1_perst_pins[] = { 29, }; -+static const int mt7623_pcie2_1_perst_funcs[] = { 6, }; -+static const int mt7623_pcie0_0_wake_pins[] = { 28, }; -+static const int mt7623_pcie0_0_wake_funcs[] = { 6, }; -+static const int mt7623_pcie0_1_wake_pins[] = { 251, }; -+static const int mt7623_pcie0_1_wake_funcs[] = { 6, }; -+static const int mt7623_pcie1_0_wake_pins[] = { 27, }; -+static const int mt7623_pcie1_0_wake_funcs[] = { 6, }; -+static const int mt7623_pcie1_1_wake_pins[] = { 253, }; -+static const int mt7623_pcie1_1_wake_funcs[] = { 6, }; -+static const int mt7623_pcie2_0_wake_pins[] = { 26, }; -+static const int mt7623_pcie2_0_wake_funcs[] = { 6, }; -+static const int mt7623_pcie2_1_wake_pins[] = { 255, }; -+static const int mt7623_pcie2_1_wake_funcs[] = { 6, }; -+static const int mt7623_pcie0_clkreq_pins[] = { 250, }; -+static const int mt7623_pcie0_clkreq_funcs[] = { 6, }; -+static const int mt7623_pcie1_clkreq_pins[] = { 252, }; -+static const int mt7623_pcie1_clkreq_funcs[] = { 6, }; -+static const int mt7623_pcie2_clkreq_pins[] = { 254, }; -+static const int mt7623_pcie2_clkreq_funcs[] = { 6, }; - /* the pcie_*_rev are only used for MT7623 */ --static int mt7623_pcie0_0_rev_perst_pins[] = { 208, }; --static int mt7623_pcie0_0_rev_perst_funcs[] = { 11, }; --static int mt7623_pcie0_1_rev_perst_pins[] = { 22, }; --static int mt7623_pcie0_1_rev_perst_funcs[] = { 10, }; --static int mt7623_pcie1_0_rev_perst_pins[] = { 209, }; --static int mt7623_pcie1_0_rev_perst_funcs[] = { 11, }; --static int mt7623_pcie1_1_rev_perst_pins[] = { 23, }; --static int mt7623_pcie1_1_rev_perst_funcs[] = { 10, }; --static int mt7623_pcie2_0_rev_perst_pins[] = { 24, }; --static int mt7623_pcie2_0_rev_perst_funcs[] = { 11, }; --static int mt7623_pcie2_1_rev_perst_pins[] = { 29, }; --static int mt7623_pcie2_1_rev_perst_funcs[] = { 14, }; -+static const int mt7623_pcie0_0_rev_perst_pins[] = { 208, }; -+static const int mt7623_pcie0_0_rev_perst_funcs[] = { 11, }; -+static const int mt7623_pcie0_1_rev_perst_pins[] = { 22, }; -+static const int mt7623_pcie0_1_rev_perst_funcs[] = { 10, }; -+static const int mt7623_pcie1_0_rev_perst_pins[] = { 209, }; -+static const int mt7623_pcie1_0_rev_perst_funcs[] = { 11, }; -+static const int mt7623_pcie1_1_rev_perst_pins[] = { 23, }; -+static const int mt7623_pcie1_1_rev_perst_funcs[] = { 10, }; -+static const int mt7623_pcie2_0_rev_perst_pins[] = { 24, }; -+static const int mt7623_pcie2_0_rev_perst_funcs[] = { 11, }; -+static const int mt7623_pcie2_1_rev_perst_pins[] = { 29, }; -+static const int mt7623_pcie2_1_rev_perst_funcs[] = { 14, }; - - /* PCM */ --static int mt7623_pcm_clk_0_pins[] = { 18, }; --static int mt7623_pcm_clk_0_funcs[] = { 1, }; --static int mt7623_pcm_clk_1_pins[] = { 17, }; --static int mt7623_pcm_clk_1_funcs[] = { 3, }; --static int mt7623_pcm_clk_2_pins[] = { 35, }; --static int mt7623_pcm_clk_2_funcs[] = { 3, }; --static int mt7623_pcm_clk_3_pins[] = { 50, }; --static int mt7623_pcm_clk_3_funcs[] = { 3, }; --static int mt7623_pcm_clk_4_pins[] = { 74, }; --static int mt7623_pcm_clk_4_funcs[] = { 3, }; --static int mt7623_pcm_clk_5_pins[] = { 191, }; --static int mt7623_pcm_clk_5_funcs[] = { 3, }; --static int mt7623_pcm_clk_6_pins[] = { 196, }; --static int mt7623_pcm_clk_6_funcs[] = { 3, }; --static int mt7623_pcm_sync_0_pins[] = { 19, }; --static int mt7623_pcm_sync_0_funcs[] = { 1, }; --static int mt7623_pcm_sync_1_pins[] = { 30, }; --static int mt7623_pcm_sync_1_funcs[] = { 3, }; --static int mt7623_pcm_sync_2_pins[] = { 36, }; --static int mt7623_pcm_sync_2_funcs[] = { 3, }; --static int mt7623_pcm_sync_3_pins[] = { 52, }; --static int mt7623_pcm_sync_3_funcs[] = { 31, }; --static int mt7623_pcm_sync_4_pins[] = { 73, }; --static int mt7623_pcm_sync_4_funcs[] = { 3, }; --static int mt7623_pcm_sync_5_pins[] = { 192, }; --static int mt7623_pcm_sync_5_funcs[] = { 3, }; --static int mt7623_pcm_sync_6_pins[] = { 197, }; --static int mt7623_pcm_sync_6_funcs[] = { 3, }; --static int mt7623_pcm_rx_0_pins[] = { 20, }; --static int mt7623_pcm_rx_0_funcs[] = { 1, }; --static int mt7623_pcm_rx_1_pins[] = { 16, }; --static int mt7623_pcm_rx_1_funcs[] = { 3, }; --static int mt7623_pcm_rx_2_pins[] = { 34, }; --static int mt7623_pcm_rx_2_funcs[] = { 3, }; --static int mt7623_pcm_rx_3_pins[] = { 51, }; --static int mt7623_pcm_rx_3_funcs[] = { 3, }; --static int mt7623_pcm_rx_4_pins[] = { 72, }; --static int mt7623_pcm_rx_4_funcs[] = { 3, }; --static int mt7623_pcm_rx_5_pins[] = { 190, }; --static int mt7623_pcm_rx_5_funcs[] = { 3, }; --static int mt7623_pcm_rx_6_pins[] = { 195, }; --static int mt7623_pcm_rx_6_funcs[] = { 3, }; --static int mt7623_pcm_tx_0_pins[] = { 21, }; --static int mt7623_pcm_tx_0_funcs[] = { 1, }; --static int mt7623_pcm_tx_1_pins[] = { 32, }; --static int mt7623_pcm_tx_1_funcs[] = { 3, }; --static int mt7623_pcm_tx_2_pins[] = { 33, }; --static int mt7623_pcm_tx_2_funcs[] = { 3, }; --static int mt7623_pcm_tx_3_pins[] = { 38, }; --static int mt7623_pcm_tx_3_funcs[] = { 3, }; --static int mt7623_pcm_tx_4_pins[] = { 49, }; --static int mt7623_pcm_tx_4_funcs[] = { 3, }; --static int mt7623_pcm_tx_5_pins[] = { 189, }; --static int mt7623_pcm_tx_5_funcs[] = { 3, }; --static int mt7623_pcm_tx_6_pins[] = { 194, }; --static int mt7623_pcm_tx_6_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_0_pins[] = { 18, }; -+static const int mt7623_pcm_clk_0_funcs[] = { 1, }; -+static const int mt7623_pcm_clk_1_pins[] = { 17, }; -+static const int mt7623_pcm_clk_1_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_2_pins[] = { 35, }; -+static const int mt7623_pcm_clk_2_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_3_pins[] = { 50, }; -+static const int mt7623_pcm_clk_3_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_4_pins[] = { 74, }; -+static const int mt7623_pcm_clk_4_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_5_pins[] = { 191, }; -+static const int mt7623_pcm_clk_5_funcs[] = { 3, }; -+static const int mt7623_pcm_clk_6_pins[] = { 196, }; -+static const int mt7623_pcm_clk_6_funcs[] = { 3, }; -+static const int mt7623_pcm_sync_0_pins[] = { 19, }; -+static const int mt7623_pcm_sync_0_funcs[] = { 1, }; -+static const int mt7623_pcm_sync_1_pins[] = { 30, }; -+static const int mt7623_pcm_sync_1_funcs[] = { 3, }; -+static const int mt7623_pcm_sync_2_pins[] = { 36, }; -+static const int mt7623_pcm_sync_2_funcs[] = { 3, }; -+static const int mt7623_pcm_sync_3_pins[] = { 52, }; -+static const int mt7623_pcm_sync_3_funcs[] = { 31, }; -+static const int mt7623_pcm_sync_4_pins[] = { 73, }; -+static const int mt7623_pcm_sync_4_funcs[] = { 3, }; -+static const int mt7623_pcm_sync_5_pins[] = { 192, }; -+static const int mt7623_pcm_sync_5_funcs[] = { 3, }; -+static const int mt7623_pcm_sync_6_pins[] = { 197, }; -+static const int mt7623_pcm_sync_6_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_0_pins[] = { 20, }; -+static const int mt7623_pcm_rx_0_funcs[] = { 1, }; -+static const int mt7623_pcm_rx_1_pins[] = { 16, }; -+static const int mt7623_pcm_rx_1_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_2_pins[] = { 34, }; -+static const int mt7623_pcm_rx_2_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_3_pins[] = { 51, }; -+static const int mt7623_pcm_rx_3_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_4_pins[] = { 72, }; -+static const int mt7623_pcm_rx_4_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_5_pins[] = { 190, }; -+static const int mt7623_pcm_rx_5_funcs[] = { 3, }; -+static const int mt7623_pcm_rx_6_pins[] = { 195, }; -+static const int mt7623_pcm_rx_6_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_0_pins[] = { 21, }; -+static const int mt7623_pcm_tx_0_funcs[] = { 1, }; -+static const int mt7623_pcm_tx_1_pins[] = { 32, }; -+static const int mt7623_pcm_tx_1_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_2_pins[] = { 33, }; -+static const int mt7623_pcm_tx_2_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_3_pins[] = { 38, }; -+static const int mt7623_pcm_tx_3_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_4_pins[] = { 49, }; -+static const int mt7623_pcm_tx_4_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_5_pins[] = { 189, }; -+static const int mt7623_pcm_tx_5_funcs[] = { 3, }; -+static const int mt7623_pcm_tx_6_pins[] = { 194, }; -+static const int mt7623_pcm_tx_6_funcs[] = { 3, }; - - /* PWM */ --static int mt7623_pwm_ch1_0_pins[] = { 203, }; --static int mt7623_pwm_ch1_0_funcs[] = { 1, }; --static int mt7623_pwm_ch1_1_pins[] = { 208, }; --static int mt7623_pwm_ch1_1_funcs[] = { 2, }; --static int mt7623_pwm_ch1_2_pins[] = { 72, }; --static int mt7623_pwm_ch1_2_funcs[] = { 4, }; --static int mt7623_pwm_ch1_3_pins[] = { 88, }; --static int mt7623_pwm_ch1_3_funcs[] = { 3, }; --static int mt7623_pwm_ch1_4_pins[] = { 108, }; --static int mt7623_pwm_ch1_4_funcs[] = { 3, }; --static int mt7623_pwm_ch2_0_pins[] = { 204, }; --static int mt7623_pwm_ch2_0_funcs[] = { 1, }; --static int mt7623_pwm_ch2_1_pins[] = { 53, }; --static int mt7623_pwm_ch2_1_funcs[] = { 5, }; --static int mt7623_pwm_ch2_2_pins[] = { 88, }; --static int mt7623_pwm_ch2_2_funcs[] = { 6, }; --static int mt7623_pwm_ch2_3_pins[] = { 108, }; --static int mt7623_pwm_ch2_3_funcs[] = { 6, }; --static int mt7623_pwm_ch2_4_pins[] = { 209, }; --static int mt7623_pwm_ch2_4_funcs[] = { 5, }; --static int mt7623_pwm_ch3_0_pins[] = { 205, }; --static int mt7623_pwm_ch3_0_funcs[] = { 1, }; --static int mt7623_pwm_ch3_1_pins[] = { 55, }; --static int mt7623_pwm_ch3_1_funcs[] = { 5, }; --static int mt7623_pwm_ch3_2_pins[] = { 89, }; --static int mt7623_pwm_ch3_2_funcs[] = { 6, }; --static int mt7623_pwm_ch3_3_pins[] = { 109, }; --static int mt7623_pwm_ch3_3_funcs[] = { 6, }; --static int mt7623_pwm_ch4_0_pins[] = { 206, }; --static int mt7623_pwm_ch4_0_funcs[] = { 1, }; --static int mt7623_pwm_ch4_1_pins[] = { 90, }; --static int mt7623_pwm_ch4_1_funcs[] = { 6, }; --static int mt7623_pwm_ch4_2_pins[] = { 110, }; --static int mt7623_pwm_ch4_2_funcs[] = { 6, }; --static int mt7623_pwm_ch4_3_pins[] = { 124, }; --static int mt7623_pwm_ch4_3_funcs[] = { 5, }; --static int mt7623_pwm_ch5_0_pins[] = { 207, }; --static int mt7623_pwm_ch5_0_funcs[] = { 1, }; --static int mt7623_pwm_ch5_1_pins[] = { 125, }; --static int mt7623_pwm_ch5_1_funcs[] = { 5, }; -+static const int mt7623_pwm_ch1_0_pins[] = { 203, }; -+static const int mt7623_pwm_ch1_0_funcs[] = { 1, }; -+static const int mt7623_pwm_ch1_1_pins[] = { 208, }; -+static const int mt7623_pwm_ch1_1_funcs[] = { 2, }; -+static const int mt7623_pwm_ch1_2_pins[] = { 72, }; -+static const int mt7623_pwm_ch1_2_funcs[] = { 4, }; -+static const int mt7623_pwm_ch1_3_pins[] = { 88, }; -+static const int mt7623_pwm_ch1_3_funcs[] = { 3, }; -+static const int mt7623_pwm_ch1_4_pins[] = { 108, }; -+static const int mt7623_pwm_ch1_4_funcs[] = { 3, }; -+static const int mt7623_pwm_ch2_0_pins[] = { 204, }; -+static const int mt7623_pwm_ch2_0_funcs[] = { 1, }; -+static const int mt7623_pwm_ch2_1_pins[] = { 53, }; -+static const int mt7623_pwm_ch2_1_funcs[] = { 5, }; -+static const int mt7623_pwm_ch2_2_pins[] = { 88, }; -+static const int mt7623_pwm_ch2_2_funcs[] = { 6, }; -+static const int mt7623_pwm_ch2_3_pins[] = { 108, }; -+static const int mt7623_pwm_ch2_3_funcs[] = { 6, }; -+static const int mt7623_pwm_ch2_4_pins[] = { 209, }; -+static const int mt7623_pwm_ch2_4_funcs[] = { 5, }; -+static const int mt7623_pwm_ch3_0_pins[] = { 205, }; -+static const int mt7623_pwm_ch3_0_funcs[] = { 1, }; -+static const int mt7623_pwm_ch3_1_pins[] = { 55, }; -+static const int mt7623_pwm_ch3_1_funcs[] = { 5, }; -+static const int mt7623_pwm_ch3_2_pins[] = { 89, }; -+static const int mt7623_pwm_ch3_2_funcs[] = { 6, }; -+static const int mt7623_pwm_ch3_3_pins[] = { 109, }; -+static const int mt7623_pwm_ch3_3_funcs[] = { 6, }; -+static const int mt7623_pwm_ch4_0_pins[] = { 206, }; -+static const int mt7623_pwm_ch4_0_funcs[] = { 1, }; -+static const int mt7623_pwm_ch4_1_pins[] = { 90, }; -+static const int mt7623_pwm_ch4_1_funcs[] = { 6, }; -+static const int mt7623_pwm_ch4_2_pins[] = { 110, }; -+static const int mt7623_pwm_ch4_2_funcs[] = { 6, }; -+static const int mt7623_pwm_ch4_3_pins[] = { 124, }; -+static const int mt7623_pwm_ch4_3_funcs[] = { 5, }; -+static const int mt7623_pwm_ch5_0_pins[] = { 207, }; -+static const int mt7623_pwm_ch5_0_funcs[] = { 1, }; -+static const int mt7623_pwm_ch5_1_pins[] = { 125, }; -+static const int mt7623_pwm_ch5_1_funcs[] = { 5, }; - - /* PWRAP */ --static int mt7623_pwrap_pins[] = { 0, 1, 2, 3, 4, 5, 6, }; --static int mt7623_pwrap_funcs[] = { 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7623_pwrap_pins[] = { 0, 1, 2, 3, 4, 5, 6, }; -+static const int mt7623_pwrap_funcs[] = { 1, 1, 1, 1, 1, 1, 1, }; - - /* SPDIF */ --static int mt7623_spdif_in0_0_pins[] = { 56, }; --static int mt7623_spdif_in0_0_funcs[] = { 3, }; --static int mt7623_spdif_in0_1_pins[] = { 201, }; --static int mt7623_spdif_in0_1_funcs[] = { 1, }; --static int mt7623_spdif_in1_0_pins[] = { 54, }; --static int mt7623_spdif_in1_0_funcs[] = { 3, }; --static int mt7623_spdif_in1_1_pins[] = { 202, }; --static int mt7623_spdif_in1_1_funcs[] = { 1, }; --static int mt7623_spdif_out_pins[] = { 202, }; --static int mt7623_spdif_out_funcs[] = { 1, }; -+static const int mt7623_spdif_in0_0_pins[] = { 56, }; -+static const int mt7623_spdif_in0_0_funcs[] = { 3, }; -+static const int mt7623_spdif_in0_1_pins[] = { 201, }; -+static const int mt7623_spdif_in0_1_funcs[] = { 1, }; -+static const int mt7623_spdif_in1_0_pins[] = { 54, }; -+static const int mt7623_spdif_in1_0_funcs[] = { 3, }; -+static const int mt7623_spdif_in1_1_pins[] = { 202, }; -+static const int mt7623_spdif_in1_1_funcs[] = { 1, }; -+static const int mt7623_spdif_out_pins[] = { 202, }; -+static const int mt7623_spdif_out_funcs[] = { 1, }; - - /* SPI */ --static int mt7623_spi0_pins[] = { 53, 54, 55, 56, }; --static int mt7623_spi0_funcs[] = { 1, 1, 1, 1, }; --static int mt7623_spi1_pins[] = { 7, 199, 8, 9, }; --static int mt7623_spi1_funcs[] = { 1, 1, 1, 1, }; --static int mt7623_spi2_pins[] = { 101, 104, 102, 103, }; --static int mt7623_spi2_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7623_spi0_pins[] = { 53, 54, 55, 56, }; -+static const int mt7623_spi0_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7623_spi1_pins[] = { 7, 199, 8, 9, }; -+static const int mt7623_spi1_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7623_spi2_pins[] = { 101, 104, 102, 103, }; -+static const int mt7623_spi2_funcs[] = { 1, 1, 1, 1, }; - - /* UART */ --static int mt7623_uart0_0_txd_rxd_pins[] = { 79, 80, }; --static int mt7623_uart0_0_txd_rxd_funcs[] = { 1, 1, }; --static int mt7623_uart0_1_txd_rxd_pins[] = { 87, 88, }; --static int mt7623_uart0_1_txd_rxd_funcs[] = { 5, 5, }; --static int mt7623_uart0_2_txd_rxd_pins[] = { 107, 108, }; --static int mt7623_uart0_2_txd_rxd_funcs[] = { 5, 5, }; --static int mt7623_uart0_3_txd_rxd_pins[] = { 123, 122, }; --static int mt7623_uart0_3_txd_rxd_funcs[] = { 5, 5, }; --static int mt7623_uart0_rts_cts_pins[] = { 22, 23, }; --static int mt7623_uart0_rts_cts_funcs[] = { 1, 1, }; --static int mt7623_uart1_0_txd_rxd_pins[] = { 81, 82, }; --static int mt7623_uart1_0_txd_rxd_funcs[] = { 1, 1, }; --static int mt7623_uart1_1_txd_rxd_pins[] = { 89, 90, }; --static int mt7623_uart1_1_txd_rxd_funcs[] = { 5, 5, }; --static int mt7623_uart1_2_txd_rxd_pins[] = { 109, 110, }; --static int mt7623_uart1_2_txd_rxd_funcs[] = { 5, 5, }; --static int mt7623_uart1_rts_cts_pins[] = { 24, 25, }; --static int mt7623_uart1_rts_cts_funcs[] = { 1, 1, }; --static int mt7623_uart2_0_txd_rxd_pins[] = { 14, 15, }; --static int mt7623_uart2_0_txd_rxd_funcs[] = { 1, 1, }; --static int mt7623_uart2_1_txd_rxd_pins[] = { 200, 201, }; --static int mt7623_uart2_1_txd_rxd_funcs[] = { 6, 6, }; --static int mt7623_uart2_rts_cts_pins[] = { 242, 243, }; --static int mt7623_uart2_rts_cts_funcs[] = { 1, 1, }; --static int mt7623_uart3_txd_rxd_pins[] = { 242, 243, }; --static int mt7623_uart3_txd_rxd_funcs[] = { 2, 2, }; --static int mt7623_uart3_rts_cts_pins[] = { 26, 27, }; --static int mt7623_uart3_rts_cts_funcs[] = { 1, 1, }; -+static const int mt7623_uart0_0_txd_rxd_pins[] = { 79, 80, }; -+static const int mt7623_uart0_0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7623_uart0_1_txd_rxd_pins[] = { 87, 88, }; -+static const int mt7623_uart0_1_txd_rxd_funcs[] = { 5, 5, }; -+static const int mt7623_uart0_2_txd_rxd_pins[] = { 107, 108, }; -+static const int mt7623_uart0_2_txd_rxd_funcs[] = { 5, 5, }; -+static const int mt7623_uart0_3_txd_rxd_pins[] = { 123, 122, }; -+static const int mt7623_uart0_3_txd_rxd_funcs[] = { 5, 5, }; -+static const int mt7623_uart0_rts_cts_pins[] = { 22, 23, }; -+static const int mt7623_uart0_rts_cts_funcs[] = { 1, 1, }; -+static const int mt7623_uart1_0_txd_rxd_pins[] = { 81, 82, }; -+static const int mt7623_uart1_0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7623_uart1_1_txd_rxd_pins[] = { 89, 90, }; -+static const int mt7623_uart1_1_txd_rxd_funcs[] = { 5, 5, }; -+static const int mt7623_uart1_2_txd_rxd_pins[] = { 109, 110, }; -+static const int mt7623_uart1_2_txd_rxd_funcs[] = { 5, 5, }; -+static const int mt7623_uart1_rts_cts_pins[] = { 24, 25, }; -+static const int mt7623_uart1_rts_cts_funcs[] = { 1, 1, }; -+static const int mt7623_uart2_0_txd_rxd_pins[] = { 14, 15, }; -+static const int mt7623_uart2_0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7623_uart2_1_txd_rxd_pins[] = { 200, 201, }; -+static const int mt7623_uart2_1_txd_rxd_funcs[] = { 6, 6, }; -+static const int mt7623_uart2_rts_cts_pins[] = { 242, 243, }; -+static const int mt7623_uart2_rts_cts_funcs[] = { 1, 1, }; -+static const int mt7623_uart3_txd_rxd_pins[] = { 242, 243, }; -+static const int mt7623_uart3_txd_rxd_funcs[] = { 2, 2, }; -+static const int mt7623_uart3_rts_cts_pins[] = { 26, 27, }; -+static const int mt7623_uart3_rts_cts_funcs[] = { 1, 1, }; - - /* Watchdog */ --static int mt7623_watchdog_0_pins[] = { 11, }; --static int mt7623_watchdog_0_funcs[] = { 1, }; --static int mt7623_watchdog_1_pins[] = { 121, }; --static int mt7623_watchdog_1_funcs[] = { 5, }; -+static const int mt7623_watchdog_0_pins[] = { 11, }; -+static const int mt7623_watchdog_0_funcs[] = { 1, }; -+static const int mt7623_watchdog_1_pins[] = { 121, }; -+static const int mt7623_watchdog_1_funcs[] = { 5, }; - - static const struct mtk_group_desc mt7623_groups[] = { - PINCTRL_PIN_GROUP("aud_ext_clk0", mt7623_aud_ext_clk0), -@@ -1362,7 +1362,7 @@ static const struct mtk_function_desc mt - {"watchdog", mt7623_wdt_groups, ARRAY_SIZE(mt7623_wdt_groups)}, - }; - --static struct mtk_pinctrl_soc mt7623_data = { -+static const struct mtk_pinctrl_soc mt7623_data = { - .name = "mt7623_pinctrl", - .reg_cal = mt7623_reg_cals, - .pins = mt7623_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt7629.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7629.c -@@ -180,118 +180,118 @@ static const struct mtk_pin_desc mt7629_ - */ - - /* WF 5G */ --static int mt7629_wf0_5g_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, }; --static int mt7629_wf0_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7629_wf0_5g_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, }; -+static const int mt7629_wf0_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - /* LED for EPHY */ --static int mt7629_ephy_leds_pins[] = { 12, 13, 14, 15, 16, 17, 18, }; --static int mt7629_ephy_leds_funcs[] = { 1, 1, 1, 1, 1, 1, 1, }; --static int mt7629_ephy_led0_pins[] = { 12, }; --static int mt7629_ephy_led0_funcs[] = { 1, }; --static int mt7629_ephy_led1_pins[] = { 13, }; --static int mt7629_ephy_led1_funcs[] = { 1, }; --static int mt7629_ephy_led2_pins[] = { 14, }; --static int mt7629_ephy_led2_funcs[] = { 1, }; --static int mt7629_ephy_led3_pins[] = { 15, }; --static int mt7629_ephy_led3_funcs[] = { 1, }; --static int mt7629_ephy_led4_pins[] = { 16, }; --static int mt7629_ephy_led4_funcs[] = { 1, }; --static int mt7629_wf2g_led_pins[] = { 17, }; --static int mt7629_wf2g_led_funcs[] = { 1, }; --static int mt7629_wf5g_led_pins[] = { 18, }; --static int mt7629_wf5g_led_funcs[] = { 1, }; -+static const int mt7629_ephy_leds_pins[] = { 12, 13, 14, 15, 16, 17, 18, }; -+static const int mt7629_ephy_leds_funcs[] = { 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7629_ephy_led0_pins[] = { 12, }; -+static const int mt7629_ephy_led0_funcs[] = { 1, }; -+static const int mt7629_ephy_led1_pins[] = { 13, }; -+static const int mt7629_ephy_led1_funcs[] = { 1, }; -+static const int mt7629_ephy_led2_pins[] = { 14, }; -+static const int mt7629_ephy_led2_funcs[] = { 1, }; -+static const int mt7629_ephy_led3_pins[] = { 15, }; -+static const int mt7629_ephy_led3_funcs[] = { 1, }; -+static const int mt7629_ephy_led4_pins[] = { 16, }; -+static const int mt7629_ephy_led4_funcs[] = { 1, }; -+static const int mt7629_wf2g_led_pins[] = { 17, }; -+static const int mt7629_wf2g_led_funcs[] = { 1, }; -+static const int mt7629_wf5g_led_pins[] = { 18, }; -+static const int mt7629_wf5g_led_funcs[] = { 1, }; - - /* LED for EPHY used as JTAG */ --static int mt7629_ephy_leds_jtag_pins[] = { 12, 13, 14, 15, 16, }; --static int mt7629_ephy_leds_jtag_funcs[] = { 7, 7, 7, 7, 7, }; -+static const int mt7629_ephy_leds_jtag_pins[] = { 12, 13, 14, 15, 16, }; -+static const int mt7629_ephy_leds_jtag_funcs[] = { 7, 7, 7, 7, 7, }; - - /* Watchdog */ --static int mt7629_watchdog_pins[] = { 11, }; --static int mt7629_watchdog_funcs[] = { 1, }; -+static const int mt7629_watchdog_pins[] = { 11, }; -+static const int mt7629_watchdog_funcs[] = { 1, }; - - /* LED for GPHY */ --static int mt7629_gphy_leds_0_pins[] = { 21, 22, 23, }; --static int mt7629_gphy_leds_0_funcs[] = { 2, 2, 2, }; --static int mt7629_gphy_led1_0_pins[] = { 21, }; --static int mt7629_gphy_led1_0_funcs[] = { 2, }; --static int mt7629_gphy_led2_0_pins[] = { 22, }; --static int mt7629_gphy_led2_0_funcs[] = { 2, }; --static int mt7629_gphy_led3_0_pins[] = { 23, }; --static int mt7629_gphy_led3_0_funcs[] = { 2, }; --static int mt7629_gphy_leds_1_pins[] = { 57, 58, 59, }; --static int mt7629_gphy_leds_1_funcs[] = { 1, 1, 1, }; --static int mt7629_gphy_led1_1_pins[] = { 57, }; --static int mt7629_gphy_led1_1_funcs[] = { 1, }; --static int mt7629_gphy_led2_1_pins[] = { 58, }; --static int mt7629_gphy_led2_1_funcs[] = { 1, }; --static int mt7629_gphy_led3_1_pins[] = { 59, }; --static int mt7629_gphy_led3_1_funcs[] = { 1, }; -+static const int mt7629_gphy_leds_0_pins[] = { 21, 22, 23, }; -+static const int mt7629_gphy_leds_0_funcs[] = { 2, 2, 2, }; -+static const int mt7629_gphy_led1_0_pins[] = { 21, }; -+static const int mt7629_gphy_led1_0_funcs[] = { 2, }; -+static const int mt7629_gphy_led2_0_pins[] = { 22, }; -+static const int mt7629_gphy_led2_0_funcs[] = { 2, }; -+static const int mt7629_gphy_led3_0_pins[] = { 23, }; -+static const int mt7629_gphy_led3_0_funcs[] = { 2, }; -+static const int mt7629_gphy_leds_1_pins[] = { 57, 58, 59, }; -+static const int mt7629_gphy_leds_1_funcs[] = { 1, 1, 1, }; -+static const int mt7629_gphy_led1_1_pins[] = { 57, }; -+static const int mt7629_gphy_led1_1_funcs[] = { 1, }; -+static const int mt7629_gphy_led2_1_pins[] = { 58, }; -+static const int mt7629_gphy_led2_1_funcs[] = { 1, }; -+static const int mt7629_gphy_led3_1_pins[] = { 59, }; -+static const int mt7629_gphy_led3_1_funcs[] = { 1, }; - - /* I2C */ --static int mt7629_i2c_0_pins[] = { 19, 20, }; --static int mt7629_i2c_0_funcs[] = { 1, 1, }; --static int mt7629_i2c_1_pins[] = { 53, 54, }; --static int mt7629_i2c_1_funcs[] = { 1, 1, }; -+static const int mt7629_i2c_0_pins[] = { 19, 20, }; -+static const int mt7629_i2c_0_funcs[] = { 1, 1, }; -+static const int mt7629_i2c_1_pins[] = { 53, 54, }; -+static const int mt7629_i2c_1_funcs[] = { 1, 1, }; - - /* SPI */ --static int mt7629_spi_0_pins[] = { 21, 22, 23, 24, }; --static int mt7629_spi_0_funcs[] = { 1, 1, 1, 1, }; --static int mt7629_spi_1_pins[] = { 62, 63, 64, 65, }; --static int mt7629_spi_1_funcs[] = { 1, 1, 1, 1, }; --static int mt7629_spi_wp_pins[] = { 66, }; --static int mt7629_spi_wp_funcs[] = { 1, }; --static int mt7629_spi_hold_pins[] = { 67, }; --static int mt7629_spi_hold_funcs[] = { 1, }; -+static const int mt7629_spi_0_pins[] = { 21, 22, 23, 24, }; -+static const int mt7629_spi_0_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7629_spi_1_pins[] = { 62, 63, 64, 65, }; -+static const int mt7629_spi_1_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7629_spi_wp_pins[] = { 66, }; -+static const int mt7629_spi_wp_funcs[] = { 1, }; -+static const int mt7629_spi_hold_pins[] = { 67, }; -+static const int mt7629_spi_hold_funcs[] = { 1, }; - - /* UART */ --static int mt7629_uart1_0_txd_rxd_pins[] = { 25, 26, }; --static int mt7629_uart1_0_txd_rxd_funcs[] = { 1, 1, }; --static int mt7629_uart1_1_txd_rxd_pins[] = { 53, 54, }; --static int mt7629_uart1_1_txd_rxd_funcs[] = { 2, 2, }; --static int mt7629_uart2_0_txd_rxd_pins[] = { 29, 30, }; --static int mt7629_uart2_0_txd_rxd_funcs[] = { 1, 1, }; --static int mt7629_uart2_1_txd_rxd_pins[] = { 57, 58, }; --static int mt7629_uart2_1_txd_rxd_funcs[] = { 2, 2, }; --static int mt7629_uart1_0_cts_rts_pins[] = { 27, 28, }; --static int mt7629_uart1_0_cts_rts_funcs[] = { 1, 1, }; --static int mt7629_uart1_1_cts_rts_pins[] = { 55, 56, }; --static int mt7629_uart1_1_cts_rts_funcs[] = { 2, 2, }; --static int mt7629_uart2_0_cts_rts_pins[] = { 31, 32, }; --static int mt7629_uart2_0_cts_rts_funcs[] = { 1, 1, }; --static int mt7629_uart2_1_cts_rts_pins[] = { 59, 60, }; --static int mt7629_uart2_1_cts_rts_funcs[] = { 2, 2, }; --static int mt7629_uart0_txd_rxd_pins[] = { 68, 69, }; --static int mt7629_uart0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7629_uart1_0_txd_rxd_pins[] = { 25, 26, }; -+static const int mt7629_uart1_0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7629_uart1_1_txd_rxd_pins[] = { 53, 54, }; -+static const int mt7629_uart1_1_txd_rxd_funcs[] = { 2, 2, }; -+static const int mt7629_uart2_0_txd_rxd_pins[] = { 29, 30, }; -+static const int mt7629_uart2_0_txd_rxd_funcs[] = { 1, 1, }; -+static const int mt7629_uart2_1_txd_rxd_pins[] = { 57, 58, }; -+static const int mt7629_uart2_1_txd_rxd_funcs[] = { 2, 2, }; -+static const int mt7629_uart1_0_cts_rts_pins[] = { 27, 28, }; -+static const int mt7629_uart1_0_cts_rts_funcs[] = { 1, 1, }; -+static const int mt7629_uart1_1_cts_rts_pins[] = { 55, 56, }; -+static const int mt7629_uart1_1_cts_rts_funcs[] = { 2, 2, }; -+static const int mt7629_uart2_0_cts_rts_pins[] = { 31, 32, }; -+static const int mt7629_uart2_0_cts_rts_funcs[] = { 1, 1, }; -+static const int mt7629_uart2_1_cts_rts_pins[] = { 59, 60, }; -+static const int mt7629_uart2_1_cts_rts_funcs[] = { 2, 2, }; -+static const int mt7629_uart0_txd_rxd_pins[] = { 68, 69, }; -+static const int mt7629_uart0_txd_rxd_funcs[] = { 1, 1, }; - - /* MDC/MDIO */ --static int mt7629_mdc_mdio_pins[] = { 49, 50, }; --static int mt7629_mdc_mdio_funcs[] = { 1, 1, }; -+static const int mt7629_mdc_mdio_pins[] = { 49, 50, }; -+static const int mt7629_mdc_mdio_funcs[] = { 1, 1, }; - - /* PCIE */ --static int mt7629_pcie_pereset_pins[] = { 51, }; --static int mt7629_pcie_pereset_funcs[] = { 1, }; --static int mt7629_pcie_wake_pins[] = { 55, }; --static int mt7629_pcie_wake_funcs[] = { 1, }; --static int mt7629_pcie_clkreq_pins[] = { 56, }; --static int mt7629_pcie_clkreq_funcs[] = { 1, }; -+static const int mt7629_pcie_pereset_pins[] = { 51, }; -+static const int mt7629_pcie_pereset_funcs[] = { 1, }; -+static const int mt7629_pcie_wake_pins[] = { 55, }; -+static const int mt7629_pcie_wake_funcs[] = { 1, }; -+static const int mt7629_pcie_clkreq_pins[] = { 56, }; -+static const int mt7629_pcie_clkreq_funcs[] = { 1, }; - - /* PWM */ --static int mt7629_pwm_0_pins[] = { 52, }; --static int mt7629_pwm_0_funcs[] = { 1, }; --static int mt7629_pwm_1_pins[] = { 61, }; --static int mt7629_pwm_1_funcs[] = { 2, }; -+static const int mt7629_pwm_0_pins[] = { 52, }; -+static const int mt7629_pwm_0_funcs[] = { 1, }; -+static const int mt7629_pwm_1_pins[] = { 61, }; -+static const int mt7629_pwm_1_funcs[] = { 2, }; - - /* WF 2G */ --static int mt7629_wf0_2g_pins[] = { 70, 71, 72, 73, 74, 75, 76, 77, 78, }; --static int mt7629_wf0_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7629_wf0_2g_pins[] = { 70, 71, 72, 73, 74, 75, 76, 77, 78, }; -+static const int mt7629_wf0_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, }; - - /* SNFI */ --static int mt7629_snfi_pins[] = { 62, 63, 64, 65, 66, 67 }; --static int mt7629_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 }; -+static const int mt7629_snfi_pins[] = { 62, 63, 64, 65, 66, 67 }; -+static const int mt7629_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 }; - - /* SPI NOR */ --static int mt7629_snor_pins[] = { 62, 63, 64, 65, 66, 67 }; --static int mt7629_snor_funcs[] = { 1, 1, 1, 1, 1, 1 }; -+static const int mt7629_snor_pins[] = { 62, 63, 64, 65, 66, 67 }; -+static const int mt7629_snor_funcs[] = { 1, 1, 1, 1, 1, 1 }; - - static const struct mtk_group_desc mt7629_groups[] = { - PINCTRL_PIN_GROUP("wf0_5g", mt7629_wf0_5g), -@@ -385,7 +385,7 @@ static const struct mtk_function_desc mt - {"jtag", mt7629_jtag_groups, ARRAY_SIZE(mt7629_jtag_groups)}, - }; - --static struct mtk_pinctrl_soc mt7629_data = { -+static const struct mtk_pinctrl_soc mt7629_data = { - .name = "mt7629_pinctrl", - .reg_cal = mt7629_reg_cals, - .pins = mt7629_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt7981.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c -@@ -570,242 +570,246 @@ static const struct mtk_pin_desc mt7981_ - }; - - /* WA_AICE */ --static int mt7981_wa_aice1_pins[] = { 0, 1, }; --static int mt7981_wa_aice1_funcs[] = { 2, 2, }; -+static const int mt7981_wa_aice1_pins[] = { 0, 1, }; -+static const int mt7981_wa_aice1_funcs[] = { 2, 2, }; - --static int mt7981_wa_aice2_pins[] = { 0, 1, }; --static int mt7981_wa_aice2_funcs[] = { 3, 3, }; -+static const int mt7981_wa_aice2_pins[] = { 0, 1, }; -+static const int mt7981_wa_aice2_funcs[] = { 3, 3, }; - --static int mt7981_wa_aice3_pins[] = { 28, 29, }; --static int mt7981_wa_aice3_funcs[] = { 3, 3, }; -+static const int mt7981_wa_aice3_pins[] = { 28, 29, }; -+static const int mt7981_wa_aice3_funcs[] = { 3, 3, }; - --static int mt7981_wm_aice1_pins[] = { 9, 10, }; --static int mt7981_wm_aice1_funcs[] = { 2, 2, }; -+static const int mt7981_wm_aice1_pins[] = { 9, 10, }; -+static const int mt7981_wm_aice1_funcs[] = { 2, 2, }; - --static int mt7981_wm_aice2_pins[] = { 30, 31, }; --static int mt7981_wm_aice2_funcs[] = { 5, 5, }; -+static const int mt7981_wm_aice2_pins[] = { 30, 31, }; -+static const int mt7981_wm_aice2_funcs[] = { 5, 5, }; - - /* WM_UART */ --static int mt7981_wm_uart_0_pins[] = { 0, 1, }; --static int mt7981_wm_uart_0_funcs[] = { 5, 5, }; -+static const int mt7981_wm_uart_0_pins[] = { 0, 1, }; -+static const int mt7981_wm_uart_0_funcs[] = { 5, 5, }; - --static int mt7981_wm_uart_1_pins[] = { 20, 21, }; --static int mt7981_wm_uart_1_funcs[] = { 4, 4, }; -+static const int mt7981_wm_uart_1_pins[] = { 20, 21, }; -+static const int mt7981_wm_uart_1_funcs[] = { 4, 4, }; - --static int mt7981_wm_uart_2_pins[] = { 30, 31, }; --static int mt7981_wm_uart_2_funcs[] = { 3, 3, }; -+static const int mt7981_wm_uart_2_pins[] = { 30, 31, }; -+static const int mt7981_wm_uart_2_funcs[] = { 3, 3, }; - - /* DFD */ --static int mt7981_dfd_pins[] = { 0, 1, 4, 5, }; --static int mt7981_dfd_funcs[] = { 5, 5, 6, 6, }; -+static const int mt7981_dfd_pins[] = { 0, 1, 4, 5, }; -+static const int mt7981_dfd_funcs[] = { 5, 5, 6, 6, }; - - /* SYS_WATCHDOG */ --static int mt7981_watchdog_pins[] = { 2, }; --static int mt7981_watchdog_funcs[] = { 1, }; -+static const int mt7981_watchdog_pins[] = { 2, }; -+static const int mt7981_watchdog_funcs[] = { 1, }; - --static int mt7981_watchdog1_pins[] = { 13, }; --static int mt7981_watchdog1_funcs[] = { 5, }; -+static const int mt7981_watchdog1_pins[] = { 13, }; -+static const int mt7981_watchdog1_funcs[] = { 5, }; - - /* PCIE_PERESET_N */ --static int mt7981_pcie_pereset_pins[] = { 3, }; --static int mt7981_pcie_pereset_funcs[] = { 1, }; -+static const int mt7981_pcie_pereset_pins[] = { 3, }; -+static const int mt7981_pcie_pereset_funcs[] = { 1, }; - - /* JTAG */ --static int mt7981_jtag_pins[] = { 4, 5, 6, 7, 8, }; --static int mt7981_jtag_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7981_jtag_pins[] = { 4, 5, 6, 7, 8, }; -+static const int mt7981_jtag_funcs[] = { 1, 1, 1, 1, 1, }; - - /* WM_JTAG */ --static int mt7981_wm_jtag_0_pins[] = { 4, 5, 6, 7, 8, }; --static int mt7981_wm_jtag_0_funcs[] = { 2, 2, 2, 2, 2, }; -+static const int mt7981_wm_jtag_0_pins[] = { 4, 5, 6, 7, 8, }; -+static const int mt7981_wm_jtag_0_funcs[] = { 2, 2, 2, 2, 2, }; - --static int mt7981_wm_jtag_1_pins[] = { 20, 21, 22, 23, 24, }; --static int mt7981_wm_jtag_1_funcs[] = { 5, 5, 5, 5, 5, }; -+static const int mt7981_wm_jtag_1_pins[] = { 20, 21, 22, 23, 24, }; -+static const int mt7981_wm_jtag_1_funcs[] = { 5, 5, 5, 5, 5, }; - - /* WO0_JTAG */ --static int mt7981_wo0_jtag_0_pins[] = { 9, 10, 11, 12, 13, }; --static int mt7981_wo0_jtag_0_funcs[] = { 1, 1, 1, 1, 1, }; -+static const int mt7981_wo0_jtag_0_pins[] = { 9, 10, 11, 12, 13, }; -+static const int mt7981_wo0_jtag_0_funcs[] = { 1, 1, 1, 1, 1, }; - --static int mt7981_wo0_jtag_1_pins[] = { 25, 26, 27, 28, 29, }; --static int mt7981_wo0_jtag_1_funcs[] = { 5, 5, 5, 5, 5, }; -+static const int mt7981_wo0_jtag_1_pins[] = { 25, 26, 27, 28, 29, }; -+static const int mt7981_wo0_jtag_1_funcs[] = { 5, 5, 5, 5, 5, }; - - /* UART2 */ --static int mt7981_uart2_0_pins[] = { 4, 5, 6, 7, }; --static int mt7981_uart2_0_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7981_uart2_0_pins[] = { 4, 5, 6, 7, }; -+static const int mt7981_uart2_0_funcs[] = { 3, 3, 3, 3, }; - - /* GBE_LED0 */ --static int mt7981_gbe_led0_pins[] = { 8, }; --static int mt7981_gbe_led0_funcs[] = { 3, }; -+static const int mt7981_gbe_led0_pins[] = { 8, }; -+static const int mt7981_gbe_led0_funcs[] = { 3, }; - - /* PTA_EXT */ --static int mt7981_pta_ext_0_pins[] = { 4, 5, 6, }; --static int mt7981_pta_ext_0_funcs[] = { 4, 4, 4, }; -+static const int mt7981_pta_ext_0_pins[] = { 4, 5, 6, }; -+static const int mt7981_pta_ext_0_funcs[] = { 4, 4, 4, }; - --static int mt7981_pta_ext_1_pins[] = { 22, 23, 24, }; --static int mt7981_pta_ext_1_funcs[] = { 4, 4, 4, }; -+static const int mt7981_pta_ext_1_pins[] = { 22, 23, 24, }; -+static const int mt7981_pta_ext_1_funcs[] = { 4, 4, 4, }; - - /* PWM2 */ --static int mt7981_pwm2_pins[] = { 7, }; --static int mt7981_pwm2_funcs[] = { 4, }; -+static const int mt7981_pwm2_pins[] = { 7, }; -+static const int mt7981_pwm2_funcs[] = { 4, }; - - /* NET_WO0_UART_TXD */ --static int mt7981_net_wo0_uart_txd_0_pins[] = { 8, }; --static int mt7981_net_wo0_uart_txd_0_funcs[] = { 4, }; -+static const int mt7981_net_wo0_uart_txd_0_pins[] = { 8, }; -+static const int mt7981_net_wo0_uart_txd_0_funcs[] = { 4, }; - --static int mt7981_net_wo0_uart_txd_1_pins[] = { 14, }; --static int mt7981_net_wo0_uart_txd_1_funcs[] = { 3, }; -+static const int mt7981_net_wo0_uart_txd_1_pins[] = { 14, }; -+static const int mt7981_net_wo0_uart_txd_1_funcs[] = { 3, }; - --static int mt7981_net_wo0_uart_txd_2_pins[] = { 15, }; --static int mt7981_net_wo0_uart_txd_2_funcs[] = { 4, }; -+static const int mt7981_net_wo0_uart_txd_2_pins[] = { 15, }; -+static const int mt7981_net_wo0_uart_txd_2_funcs[] = { 4, }; - - /* SPI1 */ --static int mt7981_spi1_0_pins[] = { 4, 5, 6, 7, }; --static int mt7981_spi1_0_funcs[] = { 5, 5, 5, 5, }; -+static const int mt7981_spi1_0_pins[] = { 4, 5, 6, 7, }; -+static const int mt7981_spi1_0_funcs[] = { 5, 5, 5, 5, }; - - /* I2C */ --static int mt7981_i2c0_0_pins[] = { 6, 7, }; --static int mt7981_i2c0_0_funcs[] = { 6, 6, }; -+static const int mt7981_i2c0_0_pins[] = { 6, 7, }; -+static const int mt7981_i2c0_0_funcs[] = { 6, 6, }; - --static int mt7981_i2c0_1_pins[] = { 30, 31, }; --static int mt7981_i2c0_1_funcs[] = { 4, 4, }; -+static const int mt7981_i2c0_1_pins[] = { 30, 31, }; -+static const int mt7981_i2c0_1_funcs[] = { 4, 4, }; - --static int mt7981_i2c0_2_pins[] = { 36, 37, }; --static int mt7981_i2c0_2_funcs[] = { 2, 2, }; -+static const int mt7981_i2c0_2_pins[] = { 36, 37, }; -+static const int mt7981_i2c0_2_funcs[] = { 2, 2, }; - --static int mt7981_u2_phy_i2c_pins[] = { 30, 31, }; --static int mt7981_u2_phy_i2c_funcs[] = { 6, 6, }; -+static const int mt7981_u2_phy_i2c_pins[] = { 30, 31, }; -+static const int mt7981_u2_phy_i2c_funcs[] = { 6, 6, }; - --static int mt7981_u3_phy_i2c_pins[] = { 32, 33, }; --static int mt7981_u3_phy_i2c_funcs[] = { 3, 3, }; -+static const int mt7981_u3_phy_i2c_pins[] = { 32, 33, }; -+static const int mt7981_u3_phy_i2c_funcs[] = { 3, 3, }; - --static int mt7981_sgmii1_phy_i2c_pins[] = { 32, 33, }; --static int mt7981_sgmii1_phy_i2c_funcs[] = { 2, 2, }; -+static const int mt7981_sgmii1_phy_i2c_pins[] = { 32, 33, }; -+static const int mt7981_sgmii1_phy_i2c_funcs[] = { 2, 2, }; - --static int mt7981_sgmii0_phy_i2c_pins[] = { 32, 33, }; --static int mt7981_sgmii0_phy_i2c_funcs[] = { 5, 5, }; -+static const int mt7981_sgmii0_phy_i2c_pins[] = { 32, 33, }; -+static const int mt7981_sgmii0_phy_i2c_funcs[] = { 5, 5, }; - - /* DFD_NTRST */ --static int mt7981_dfd_ntrst_pins[] = { 8, }; --static int mt7981_dfd_ntrst_funcs[] = { 6, }; -+static const int mt7981_dfd_ntrst_pins[] = { 8, }; -+static const int mt7981_dfd_ntrst_funcs[] = { 6, }; - - /* PWM0 */ --static int mt7981_pwm0_0_pins[] = { 13, }; --static int mt7981_pwm0_0_funcs[] = { 2, }; -+static const int mt7981_pwm0_0_pins[] = { 13, }; -+static const int mt7981_pwm0_0_funcs[] = { 2, }; - --static int mt7981_pwm0_1_pins[] = { 15, }; --static int mt7981_pwm0_1_funcs[] = { 1, }; -+static const int mt7981_pwm0_1_pins[] = { 15, }; -+static const int mt7981_pwm0_1_funcs[] = { 1, }; - - /* PWM1 */ --static int mt7981_pwm1_0_pins[] = { 14, }; --static int mt7981_pwm1_0_funcs[] = { 2, }; -+static const int mt7981_pwm1_0_pins[] = { 14, }; -+static const int mt7981_pwm1_0_funcs[] = { 2, }; - --static int mt7981_pwm1_1_pins[] = { 15, }; --static int mt7981_pwm1_1_funcs[] = { 3, }; -+static const int mt7981_pwm1_1_pins[] = { 15, }; -+static const int mt7981_pwm1_1_funcs[] = { 3, }; - - /* GBE_LED1 */ --static int mt7981_gbe_led1_pins[] = { 13, }; --static int mt7981_gbe_led1_funcs[] = { 3, }; -+static const int mt7981_gbe_led1_pins[] = { 13, }; -+static const int mt7981_gbe_led1_funcs[] = { 3, }; - - /* PCM */ --static int mt7981_pcm_pins[] = { 9, 10, 11, 12, 13, 25 }; --static int mt7981_pcm_funcs[] = { 4, 4, 4, 4, 4, 4, }; -+static const int mt7981_pcm_pins[] = { 9, 10, 11, 12, 13, 25 }; -+static const int mt7981_pcm_funcs[] = { 4, 4, 4, 4, 4, 4, }; - - /* UDI */ --static int mt7981_udi_pins[] = { 9, 10, 11, 12, 13, }; --static int mt7981_udi_funcs[] = { 6, 6, 6, 6, 6, }; -+static const int mt7981_udi_pins[] = { 9, 10, 11, 12, 13, }; -+static const int mt7981_udi_funcs[] = { 6, 6, 6, 6, 6, }; - - /* DRV_VBUS */ --static int mt7981_drv_vbus_pins[] = { 14, }; --static int mt7981_drv_vbus_funcs[] = { 1, }; -+static const int mt7981_drv_vbus_pins[] = { 14, }; -+static const int mt7981_drv_vbus_funcs[] = { 1, }; - - /* EMMC */ --static int mt7981_emmc_45_pins[] = { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, }; --static int mt7981_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; -+static const int mt7981_emmc_45_pins[] = { -+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, }; -+static const int mt7981_emmc_45_funcs[] = { -+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; - - /* SNFI */ --static int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, }; --static int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, }; -+static const int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, }; -+static const int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, }; - - /* SPI0 */ --static int mt7981_spi0_pins[] = { 16, 17, 18, 19, }; --static int mt7981_spi0_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7981_spi0_pins[] = { 16, 17, 18, 19, }; -+static const int mt7981_spi0_funcs[] = { 1, 1, 1, 1, }; - - /* SPI0 */ --static int mt7981_spi0_wp_hold_pins[] = { 20, 21, }; --static int mt7981_spi0_wp_hold_funcs[] = { 1, 1, }; -+static const int mt7981_spi0_wp_hold_pins[] = { 20, 21, }; -+static const int mt7981_spi0_wp_hold_funcs[] = { 1, 1, }; - - /* SPI1 */ --static int mt7981_spi1_1_pins[] = { 22, 23, 24, 25, }; --static int mt7981_spi1_1_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7981_spi1_1_pins[] = { 22, 23, 24, 25, }; -+static const int mt7981_spi1_1_funcs[] = { 1, 1, 1, 1, }; - - /* SPI2 */ --static int mt7981_spi2_pins[] = { 26, 27, 28, 29, }; --static int mt7981_spi2_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7981_spi2_pins[] = { 26, 27, 28, 29, }; -+static const int mt7981_spi2_funcs[] = { 1, 1, 1, 1, }; - - /* SPI2 */ --static int mt7981_spi2_wp_hold_pins[] = { 30, 31, }; --static int mt7981_spi2_wp_hold_funcs[] = { 1, 1, }; -+static const int mt7981_spi2_wp_hold_pins[] = { 30, 31, }; -+static const int mt7981_spi2_wp_hold_funcs[] = { 1, 1, }; - - /* UART1 */ --static int mt7981_uart1_0_pins[] = { 16, 17, 18, 19, }; --static int mt7981_uart1_0_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7981_uart1_0_pins[] = { 16, 17, 18, 19, }; -+static const int mt7981_uart1_0_funcs[] = { 4, 4, 4, 4, }; - --static int mt7981_uart1_1_pins[] = { 26, 27, 28, 29, }; --static int mt7981_uart1_1_funcs[] = { 2, 2, 2, 2, }; -+static const int mt7981_uart1_1_pins[] = { 26, 27, 28, 29, }; -+static const int mt7981_uart1_1_funcs[] = { 2, 2, 2, 2, }; - - /* UART2 */ --static int mt7981_uart2_1_pins[] = { 22, 23, 24, 25, }; --static int mt7981_uart2_1_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7981_uart2_1_pins[] = { 22, 23, 24, 25, }; -+static const int mt7981_uart2_1_funcs[] = { 3, 3, 3, 3, }; - - /* UART0 */ --static int mt7981_uart0_pins[] = { 32, 33, }; --static int mt7981_uart0_funcs[] = { 1, 1, }; -+static const int mt7981_uart0_pins[] = { 32, 33, }; -+static const int mt7981_uart0_funcs[] = { 1, 1, }; - - /* PCIE_CLK_REQ */ --static int mt7981_pcie_clk_pins[] = { 34, }; --static int mt7981_pcie_clk_funcs[] = { 2, }; -+static const int mt7981_pcie_clk_pins[] = { 34, }; -+static const int mt7981_pcie_clk_funcs[] = { 2, }; - - /* PCIE_WAKE_N */ --static int mt7981_pcie_wake_pins[] = { 35, }; --static int mt7981_pcie_wake_funcs[] = { 2, }; -+static const int mt7981_pcie_wake_pins[] = { 35, }; -+static const int mt7981_pcie_wake_funcs[] = { 2, }; - - /* MDC_MDIO */ --static int mt7981_smi_mdc_mdio_pins[] = { 36, 37, }; --static int mt7981_smi_mdc_mdio_funcs[] = { 1, 1, }; -+static const int mt7981_smi_mdc_mdio_pins[] = { 36, 37, }; -+static const int mt7981_smi_mdc_mdio_funcs[] = { 1, 1, }; - --static int mt7981_gbe_ext_mdc_mdio_pins[] = { 36, 37, }; --static int mt7981_gbe_ext_mdc_mdio_funcs[] = { 3, 3, }; -+static const int mt7981_gbe_ext_mdc_mdio_pins[] = { 36, 37, }; -+static const int mt7981_gbe_ext_mdc_mdio_funcs[] = { 3, 3, }; - - /* WF0_MODE1 */ --static int mt7981_wf0_mode1_pins[] = { 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, -- 50, 51, 52, 53, 54, 55, 56 }; --static int mt7981_wf0_mode1_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -- 1, 1, 1, 1 }; -+static const int mt7981_wf0_mode1_pins[] = { -+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 }; -+static const int mt7981_wf0_mode1_funcs[] = { -+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - - /* WF0_MODE3 */ --static int mt7981_wf0_mode3_pins[] = { 45, 46, 47, 48, 49, 51 }; --static int mt7981_wf0_mode3_funcs[] = { 2, 2, 2, 2, 2, 2 }; -+static const int mt7981_wf0_mode3_pins[] = { 45, 46, 47, 48, 49, 51 }; -+static const int mt7981_wf0_mode3_funcs[] = { 2, 2, 2, 2, 2, 2 }; - - /* WF2G_LED */ --static int mt7981_wf2g_led0_pins[] = { 30, }; --static int mt7981_wf2g_led0_funcs[] = { 2, }; -+static const int mt7981_wf2g_led0_pins[] = { 30, }; -+static const int mt7981_wf2g_led0_funcs[] = { 2, }; - --static int mt7981_wf2g_led1_pins[] = { 34, }; --static int mt7981_wf2g_led1_funcs[] = { 1, }; -+static const int mt7981_wf2g_led1_pins[] = { 34, }; -+static const int mt7981_wf2g_led1_funcs[] = { 1, }; - - /* WF5G_LED */ --static int mt7981_wf5g_led0_pins[] = { 31, }; --static int mt7981_wf5g_led0_funcs[] = { 2, }; -+static const int mt7981_wf5g_led0_pins[] = { 31, }; -+static const int mt7981_wf5g_led0_funcs[] = { 2, }; - --static int mt7981_wf5g_led1_pins[] = { 35, }; --static int mt7981_wf5g_led1_funcs[] = { 1, }; -+static const int mt7981_wf5g_led1_pins[] = { 35, }; -+static const int mt7981_wf5g_led1_funcs[] = { 1, }; - - /* MT7531_INT */ --static int mt7981_mt7531_int_pins[] = { 38, }; --static int mt7981_mt7531_int_funcs[] = { 1, }; -+static const int mt7981_mt7531_int_pins[] = { 38, }; -+static const int mt7981_mt7531_int_funcs[] = { 1, }; - - /* ANT_SEL */ --static int mt7981_ant_sel_pins[] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 34, 35 }; --static int mt7981_ant_sel_funcs[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }; -+static const int mt7981_ant_sel_pins[] = { -+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 34, 35 }; -+static const int mt7981_ant_sel_funcs[] = { -+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }; - - static const struct mtk_group_desc mt7981_groups[] = { - /* @GPIO(0,1): WA_AICE(2) */ -@@ -1012,7 +1016,7 @@ static const char *const mt7981_pinctrl_ - "iocfg_lb_base", "iocfg_bl_base", "iocfg_tm_base", "iocfg_tl_base", - }; - --static struct mtk_pinctrl_soc mt7981_data = { -+static const struct mtk_pinctrl_soc mt7981_data = { - .name = "mt7981_pinctrl", - .reg_cal = mt7981_reg_cals, - .pins = mt7981_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c -@@ -554,114 +554,117 @@ static const struct mtk_io_type_desc mt7 - * The hardware probably has multiple combinations of these pinouts. - */ - --static int mt7986_watchdog_pins[] = { 0, }; --static int mt7986_watchdog_funcs[] = { 1, }; -+static const int mt7986_watchdog_pins[] = { 0, }; -+static const int mt7986_watchdog_funcs[] = { 1, }; - --static int mt7986_wifi_led_pins[] = { 1, 2, }; --static int mt7986_wifi_led_funcs[] = { 1, 1, }; -+static const int mt7986_wifi_led_pins[] = { 1, 2, }; -+static const int mt7986_wifi_led_funcs[] = { 1, 1, }; - --static int mt7986_i2c_pins[] = { 3, 4, }; --static int mt7986_i2c_funcs[] = { 1, 1, }; -+static const int mt7986_i2c_pins[] = { 3, 4, }; -+static const int mt7986_i2c_funcs[] = { 1, 1, }; - --static int mt7986_uart1_0_pins[] = { 7, 8, 9, 10, }; --static int mt7986_uart1_0_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7986_uart1_0_pins[] = { 7, 8, 9, 10, }; -+static const int mt7986_uart1_0_funcs[] = { 3, 3, 3, 3, }; - --static int mt7986_spi1_0_pins[] = { 11, 12, 13, 14, }; --static int mt7986_spi1_0_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7986_spi1_0_pins[] = { 11, 12, 13, 14, }; -+static const int mt7986_spi1_0_funcs[] = { 3, 3, 3, 3, }; - --static int mt7986_pwm1_1_pins[] = { 20, }; --static int mt7986_pwm1_1_funcs[] = { 2, }; -+static const int mt7986_pwm1_1_pins[] = { 20, }; -+static const int mt7986_pwm1_1_funcs[] = { 2, }; - --static int mt7986_pwm0_pins[] = { 21, }; --static int mt7986_pwm0_funcs[] = { 1, }; -+static const int mt7986_pwm0_pins[] = { 21, }; -+static const int mt7986_pwm0_funcs[] = { 1, }; - --static int mt7986_pwm1_0_pins[] = { 22, }; --static int mt7986_pwm1_0_funcs[] = { 1, }; -+static const int mt7986_pwm1_0_pins[] = { 22, }; -+static const int mt7986_pwm1_0_funcs[] = { 1, }; - --static int mt7986_emmc_45_pins[] = { -+static const int mt7986_emmc_45_pins[] = { - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, }; --static int mt7986_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; -+static const int mt7986_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; - --static int mt7986_snfi_pins[] = { 23, 24, 25, 26, 27, 28, }; --static int mt7986_snfi_funcs[] = { 1, 1, 1, 1, 1, 1, }; -+static const int mt7986_snfi_pins[] = { 23, 24, 25, 26, 27, 28, }; -+static const int mt7986_snfi_funcs[] = { 1, 1, 1, 1, 1, 1, }; - --static int mt7986_spi1_1_pins[] = { 23, 24, 25, 26, }; --static int mt7986_spi1_1_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7986_spi1_1_pins[] = { 23, 24, 25, 26, }; -+static const int mt7986_spi1_1_funcs[] = { 3, 3, 3, 3, }; - --static int mt7986_uart1_1_pins[] = { 23, 24, 25, 26, }; --static int mt7986_uart1_1_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7986_uart1_1_pins[] = { 23, 24, 25, 26, }; -+static const int mt7986_uart1_1_funcs[] = { 4, 4, 4, 4, }; - --static int mt7986_spi1_2_pins[] = { 29, 30, 31, 32, }; --static int mt7986_spi1_2_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_spi1_2_pins[] = { 29, 30, 31, 32, }; -+static const int mt7986_spi1_2_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_uart1_2_pins[] = { 29, 30, 31, 32, }; --static int mt7986_uart1_2_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7986_uart1_2_pins[] = { 29, 30, 31, 32, }; -+static const int mt7986_uart1_2_funcs[] = { 3, 3, 3, 3, }; - --static int mt7986_uart2_0_pins[] = { 29, 30, 31, 32, }; --static int mt7986_uart2_0_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7986_uart2_0_pins[] = { 29, 30, 31, 32, }; -+static const int mt7986_uart2_0_funcs[] = { 4, 4, 4, 4, }; - --static int mt7986_spi0_pins[] = { 33, 34, 35, 36, }; --static int mt7986_spi0_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_spi0_pins[] = { 33, 34, 35, 36, }; -+static const int mt7986_spi0_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_spi0_wp_hold_pins[] = { 37, 38, }; --static int mt7986_spi0_wp_hold_funcs[] = { 1, 1, }; -+static const int mt7986_spi0_wp_hold_pins[] = { 37, 38, }; -+static const int mt7986_spi0_wp_hold_funcs[] = { 1, 1, }; - --static int mt7986_uart2_1_pins[] = { 33, 34, 35, 36, }; --static int mt7986_uart2_1_funcs[] = { 3, 3, 3, 3, }; -+static const int mt7986_uart2_1_pins[] = { 33, 34, 35, 36, }; -+static const int mt7986_uart2_1_funcs[] = { 3, 3, 3, 3, }; - --static int mt7986_uart1_3_rx_tx_pins[] = { 35, 36, }; --static int mt7986_uart1_3_rx_tx_funcs[] = { 2, 2, }; -+static const int mt7986_uart1_3_rx_tx_pins[] = { 35, 36, }; -+static const int mt7986_uart1_3_rx_tx_funcs[] = { 2, 2, }; - --static int mt7986_uart1_3_cts_rts_pins[] = { 37, 38, }; --static int mt7986_uart1_3_cts_rts_funcs[] = { 2, 2, }; -+static const int mt7986_uart1_3_cts_rts_pins[] = { 37, 38, }; -+static const int mt7986_uart1_3_cts_rts_funcs[] = { 2, 2, }; - --static int mt7986_spi1_3_pins[] = { 33, 34, 35, 36, }; --static int mt7986_spi1_3_funcs[] = { 4, 4, 4, 4, }; -+static const int mt7986_spi1_3_pins[] = { 33, 34, 35, 36, }; -+static const int mt7986_spi1_3_funcs[] = { 4, 4, 4, 4, }; - --static int mt7986_uart0_pins[] = { 39, 40, }; --static int mt7986_uart0_funcs[] = { 1, 1, }; -+static const int mt7986_uart0_pins[] = { 39, 40, }; -+static const int mt7986_uart0_funcs[] = { 1, 1, }; - --static int mt7986_pcie_reset_pins[] = { 41, }; --static int mt7986_pcie_reset_funcs[] = { 1, }; -+static const int mt7986_pcie_reset_pins[] = { 41, }; -+static const int mt7986_pcie_reset_funcs[] = { 1, }; - --static int mt7986_uart1_pins[] = { 42, 43, 44, 45, }; --static int mt7986_uart1_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_uart1_pins[] = { 42, 43, 44, 45, }; -+static const int mt7986_uart1_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_uart2_pins[] = { 46, 47, 48, 49, }; --static int mt7986_uart2_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_uart2_pins[] = { 46, 47, 48, 49, }; -+static const int mt7986_uart2_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_emmc_51_pins[] = { -+static const int mt7986_emmc_51_pins[] = { - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, }; --static int mt7986_emmc_51_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7986_emmc_51_funcs[] = { -+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - --static int mt7986_pcm_pins[] = { 62, 63, 64, 65, }; --static int mt7986_pcm_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_pcm_pins[] = { 62, 63, 64, 65, }; -+static const int mt7986_pcm_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_i2s_pins[] = { 62, 63, 64, 65, }; --static int mt7986_i2s_funcs[] = { 1, 1, 1, 1, }; -+static const int mt7986_i2s_pins[] = { 62, 63, 64, 65, }; -+static const int mt7986_i2s_funcs[] = { 1, 1, 1, 1, }; - --static int mt7986_switch_int_pins[] = { 66, }; --static int mt7986_switch_int_funcs[] = { 1, }; -+static const int mt7986_switch_int_pins[] = { 66, }; -+static const int mt7986_switch_int_funcs[] = { 1, }; - --static int mt7986_mdc_mdio_pins[] = { 67, 68, }; --static int mt7986_mdc_mdio_funcs[] = { 1, 1, }; -+static const int mt7986_mdc_mdio_pins[] = { 67, 68, }; -+static const int mt7986_mdc_mdio_funcs[] = { 1, 1, }; - --static int mt7986_wf_2g_pins[] = {74, 75, 76, 77, 78, 79, 80, 81, 82, 83, }; --static int mt7986_wf_2g_funcs[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7986_wf_2g_pins[] = { -+ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, }; -+static const int mt7986_wf_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - --static int mt7986_wf_5g_pins[] = {91, 92, 93, 94, 95, 96, 97, 98, 99, 100, }; --static int mt7986_wf_5g_funcs[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt7986_wf_5g_pins[] = { -+ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, }; -+static const int mt7986_wf_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - --static int mt7986_wf_dbdc_pins[] = { -+static const int mt7986_wf_dbdc_pins[] = { - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, }; --static int mt7986_wf_dbdc_funcs[] = { -+static const int mt7986_wf_dbdc_funcs[] = { - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; - --static int mt7986_pcie_clk_pins[] = { 9, }; --static int mt7986_pcie_clk_funcs[] = { 1, }; -+static const int mt7986_pcie_clk_pins[] = { 9, }; -+static const int mt7986_pcie_clk_funcs[] = { 1, }; - --static int mt7986_pcie_wake_pins[] = { 10, }; --static int mt7986_pcie_wake_funcs[] = { 1, }; -+static const int mt7986_pcie_wake_pins[] = { 10, }; -+static const int mt7986_pcie_wake_funcs[] = { 1, }; - - static const struct mtk_group_desc mt7986_groups[] = { - PINCTRL_PIN_GROUP("watchdog", mt7986_watchdog), -@@ -738,7 +741,7 @@ static const struct mtk_function_desc mt - {"wifi", mt7986_wf_groups, ARRAY_SIZE(mt7986_wf_groups)}, - }; - --static struct mtk_pinctrl_soc mt7986_data = { -+static const struct mtk_pinctrl_soc mt7986_data = { - .name = "mt7986_pinctrl", - .reg_cal = mt7986_reg_cals, - .pins = mt7986_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt8512.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt8512.c -@@ -315,12 +315,12 @@ static const struct mtk_pin_desc mt8512_ - */ - - /* UART */ --static int mt8512_uart0_0_rxd_txd_pins[] = { 52, 53, }; --static int mt8512_uart0_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8512_uart1_0_rxd_txd_pins[] = { 54, 55, }; --static int mt8512_uart1_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8512_uart2_0_rxd_txd_pins[] = { 28, 29, }; --static int mt8512_uart2_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8512_uart0_0_rxd_txd_pins[] = { 52, 53, }; -+static const int mt8512_uart0_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8512_uart1_0_rxd_txd_pins[] = { 54, 55, }; -+static const int mt8512_uart1_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8512_uart2_0_rxd_txd_pins[] = { 28, 29, }; -+static const int mt8512_uart2_0_rxd_txd_funcs[] = { 1, 1, }; - - /* Joint those groups owning the same capability in user point of view which - * allows that people tend to use through the device tree. -@@ -330,13 +330,13 @@ static const char *const mt8512_uart_gro - "uart2_0_rxd_txd", }; - - /* SNAND */ --static int mt8512_snfi_pins[] = { 71, 76, 77, 78, 79, 80, }; --static int mt8512_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, }; -+static const int mt8512_snfi_pins[] = { 71, 76, 77, 78, 79, 80, }; -+static const int mt8512_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, }; - - /* MMC0 */ --static int mt8512_msdc0_pins[] = { 76, 77, 78, 79, 80, 81, 82, 83, 84, -- 85, 86, }; --static int mt8512_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt8512_msdc0_pins[] = { 76, 77, 78, 79, 80, 81, 82, 83, 84, -+ 85, 86, }; -+static const int mt8512_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - static const struct mtk_group_desc mt8512_groups[] = { - PINCTRL_PIN_GROUP("uart0_0_rxd_txd", mt8512_uart0_0_rxd_txd), -@@ -356,7 +356,7 @@ static const struct mtk_function_desc mt - {"snand", mt8512_msdc_groups, ARRAY_SIZE(mt8512_msdc_groups)}, - }; - --static struct mtk_pinctrl_soc mt8512_data = { -+static const struct mtk_pinctrl_soc mt8512_data = { - .name = "mt8512_pinctrl", - .reg_cal = mt8512_reg_cals, - .pins = mt8512_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c -@@ -326,12 +326,12 @@ static const struct mtk_pin_desc mt8516_ - */ - - /* UART */ --static int mt8516_uart0_0_rxd_txd_pins[] = { 62, 63, }; --static int mt8516_uart0_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8516_uart1_0_rxd_txd_pins[] = { 64, 65, }; --static int mt8516_uart1_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8516_uart2_0_rxd_txd_pins[] = { 34, 35, }; --static int mt8516_uart2_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8516_uart0_0_rxd_txd_pins[] = { 62, 63, }; -+static const int mt8516_uart0_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8516_uart1_0_rxd_txd_pins[] = { 64, 65, }; -+static const int mt8516_uart1_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8516_uart2_0_rxd_txd_pins[] = { 34, 35, }; -+static const int mt8516_uart2_0_rxd_txd_funcs[] = { 1, 1, }; - - /* Joint those groups owning the same capability in user point of view which - * allows that people tend to use through the device tree. -@@ -341,9 +341,9 @@ static const char *const mt8516_uart_gro - "uart2_0_rxd_txd", }; - - /* MMC0 */ --static int mt8516_msdc0_pins[] = { 110, 111, 112, 113, 114, 115, 116, 117, 118, -- 119, 120, }; --static int mt8516_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt8516_msdc0_pins[] = { 110, 111, 112, 113, 114, 115, 116, 117, -+ 118, 119, 120, }; -+static const int mt8516_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - static const struct mtk_group_desc mt8516_groups[] = { - PINCTRL_PIN_GROUP("uart0_0_rxd_txd", mt8516_uart0_0_rxd_txd), ---- a/drivers/pinctrl/mediatek/pinctrl-mt8518.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mt8518.c -@@ -346,12 +346,12 @@ static const struct mtk_pin_desc mt8518_ - */ - - /* UART */ --static int mt8518_uart0_0_rxd_txd_pins[] = { 104, 105, }; --static int mt8518_uart0_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8518_uart1_0_rxd_txd_pins[] = { 52, 53, }; --static int mt8518_uart1_0_rxd_txd_funcs[] = { 1, 1, }; --static int mt8518_uart2_0_rxd_txd_pins[] = { 106, 107, }; --static int mt8518_uart2_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8518_uart0_0_rxd_txd_pins[] = { 104, 105, }; -+static const int mt8518_uart0_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8518_uart1_0_rxd_txd_pins[] = { 52, 53, }; -+static const int mt8518_uart1_0_rxd_txd_funcs[] = { 1, 1, }; -+static const int mt8518_uart2_0_rxd_txd_pins[] = { 106, 107, }; -+static const int mt8518_uart2_0_rxd_txd_funcs[] = { 1, 1, }; - - /* Joint those groups owning the same capability in user point of view which - * allows that people tend to use through the device tree. -@@ -361,9 +361,9 @@ static const char *const mt8518_uart_gro - "uart2_0_rxd_txd", }; - - /* MMC0 */ --static int mt8518_msdc0_pins[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, -- 12, 13, }; --static int mt8518_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -+static const int mt8518_msdc0_pins[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, -+ 12, 13, }; -+static const int mt8518_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; - - static const struct mtk_group_desc mt8518_groups[] = { - PINCTRL_PIN_GROUP("uart0_0_rxd_txd", mt8518_uart0_0_rxd_txd), -@@ -380,7 +380,7 @@ static const struct mtk_function_desc mt - {"msdc", mt8518_msdc_groups, ARRAY_SIZE(mt8518_msdc_groups)}, - }; - --static struct mtk_pinctrl_soc mt8518_data = { -+static const struct mtk_pinctrl_soc mt8518_data = { - .name = "mt8518_pinctrl", - .reg_cal = mt8518_reg_cals, - .pins = mt8518_pins, ---- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -@@ -314,7 +314,7 @@ static int mtk_pinmux_group_set(struct u - int i; - - for (i = 0; i < grp->num_pins; i++) { -- int *pin_modes = grp->data; -+ const int *pin_modes = grp->data; - - mtk_hw_set_value(dev, grp->pins[i], PINCTRL_PIN_REG_MODE, - pin_modes[i]); -@@ -769,7 +769,7 @@ static int mtk_gpiochip_register(struct - #endif - - int mtk_pinctrl_common_probe(struct udevice *dev, -- struct mtk_pinctrl_soc *soc) -+ const struct mtk_pinctrl_soc *soc) - { - struct mtk_pinctrl_priv *priv = dev_get_priv(dev); - int ret = 0; ---- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h -+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h -@@ -174,9 +174,9 @@ struct mtk_pin_desc { - */ - struct mtk_group_desc { - const char *name; -- int *pins; -+ const int *pins; - int num_pins; -- void *data; -+ const void *data; - }; - - /** -@@ -233,7 +233,7 @@ struct mtk_pinctrl_soc { - */ - struct mtk_pinctrl_priv { - void __iomem *base[MAX_BASE_CALC]; -- struct mtk_pinctrl_soc *soc; -+ const struct mtk_pinctrl_soc *soc; - }; - - extern const struct pinctrl_ops mtk_pinctrl_ops; -@@ -242,7 +242,7 @@ extern const struct pinctrl_ops mtk_pinc - void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set); - void mtk_i_rmw(struct udevice *dev, u8 i, u32 reg, u32 mask, u32 set); - int mtk_pinctrl_common_probe(struct udevice *dev, -- struct mtk_pinctrl_soc *soc); -+ const struct mtk_pinctrl_soc *soc); - - #if CONFIG_IS_ENABLED(PINCONF) - diff --git a/package/boot/uboot-mediatek/patches/101-13-pinctrl-mediatek-fix-the-return-value-in-driving-con.patch b/package/boot/uboot-mediatek/patches/101-13-pinctrl-mediatek-fix-the-return-value-in-driving-con.patch deleted file mode 100644 index d83a89ab37e205..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-13-pinctrl-mediatek-fix-the-return-value-in-driving-con.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 783c46d29f8b186bd65f3e83f38ad883e8bcec69 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:42 +0800 -Subject: [PATCH 13/29] pinctrl: mediatek: fix the return value in driving - configuration functions - -The original mediatek pinctrl functions for driving configuration -'mtk_pinconf_drive_set_*' do not return -ENOSUPP even if input -parameters are not supported. -This patch fixes the return value in those functions. - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -@@ -513,7 +513,7 @@ int mtk_pinconf_drive_set_v0(struct udev - return err; - } - -- return 0; -+ return err; - } - - int mtk_pinconf_drive_set_v1(struct udevice *dev, u32 pin, u32 arg) -@@ -531,7 +531,7 @@ int mtk_pinconf_drive_set_v1(struct udev - return err; - } - -- return 0; -+ return err; - } - - int mtk_pinconf_drive_set(struct udevice *dev, u32 pin, u32 arg) diff --git a/package/boot/uboot-mediatek/patches/101-14-pinctrl-mediatek-add-pinmux_set-ops-support.patch b/package/boot/uboot-mediatek/patches/101-14-pinctrl-mediatek-add-pinmux_set-ops-support.patch deleted file mode 100644 index 7cb185ff42c342..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-14-pinctrl-mediatek-add-pinmux_set-ops-support.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 090351b416e57e0f7b5d1a4c87d4ed9ab4f5c89b Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:46 +0800 -Subject: [PATCH 14/29] pinctrl: mediatek: add pinmux_set ops support - -This patch adds pinmux_set ops for mediatek pinctrl framework - -Signed-off-by: Sam Shih -Signed-off-by: Weijie Gao ---- - drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - ---- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c -@@ -304,6 +304,19 @@ static const char *mtk_get_function_name - return priv->soc->funcs[selector].name; - } - -+static int mtk_pinmux_set(struct udevice *dev, unsigned int pin_selector, -+ unsigned int func_selector) -+{ -+ int err; -+ -+ err = mtk_hw_set_value(dev, pin_selector, PINCTRL_PIN_REG_MODE, -+ func_selector); -+ if (err) -+ return err; -+ -+ return 0; -+} -+ - static int mtk_pinmux_group_set(struct udevice *dev, - unsigned int group_selector, - unsigned int func_selector) -@@ -647,6 +660,7 @@ const struct pinctrl_ops mtk_pinctrl_ops - .get_group_name = mtk_get_group_name, - .get_functions_count = mtk_get_functions_count, - .get_function_name = mtk_get_function_name, -+ .pinmux_set = mtk_pinmux_set, - .pinmux_group_set = mtk_pinmux_group_set, - #if CONFIG_IS_ENABLED(PINCONF) - .pinconf_num_params = ARRAY_SIZE(mtk_conf_params), diff --git a/package/boot/uboot-mediatek/patches/101-15-pinctrl-mediatek-add-pinctrl-driver-for-MT7988-SoC.patch b/package/boot/uboot-mediatek/patches/101-15-pinctrl-mediatek-add-pinctrl-driver-for-MT7988-SoC.patch deleted file mode 100644 index cfc7c32ba317e3..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-15-pinctrl-mediatek-add-pinctrl-driver-for-MT7988-SoC.patch +++ /dev/null @@ -1,1315 +0,0 @@ -From 5e821f4ebd9da4ccf3c8871e402996f6a6eb8d1c Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:50 +0800 -Subject: [PATCH 15/29] pinctrl: mediatek: add pinctrl driver for MT7988 SoC - -This patch adds pinctrl and gpio support for MT7988 SoC - -Signed-off-by: Weijie Gao ---- - drivers/pinctrl/mediatek/Kconfig | 4 + - drivers/pinctrl/mediatek/Makefile | 1 + - drivers/pinctrl/mediatek/pinctrl-mt7988.c | 1274 +++++++++++++++++++++ - 3 files changed, 1279 insertions(+) - create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7988.c - ---- a/drivers/pinctrl/mediatek/Kconfig -+++ b/drivers/pinctrl/mediatek/Kconfig -@@ -24,6 +24,10 @@ config PINCTRL_MT7986 - bool "MT7986 SoC pinctrl driver" - select PINCTRL_MTK - -+config PINCTRL_MT7988 -+ bool "MT7988 SoC pinctrl driver" -+ select PINCTRL_MTK -+ - config PINCTRL_MT8512 - bool "MT8512 SoC pinctrl driver" - select PINCTRL_MTK ---- a/drivers/pinctrl/mediatek/Makefile -+++ b/drivers/pinctrl/mediatek/Makefile -@@ -8,6 +8,7 @@ obj-$(CONFIG_PINCTRL_MT7623) += pinctrl- - obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o - obj-$(CONFIG_PINCTRL_MT7981) += pinctrl-mt7981.o - obj-$(CONFIG_PINCTRL_MT7986) += pinctrl-mt7986.o -+obj-$(CONFIG_PINCTRL_MT7988) += pinctrl-mt7988.o - obj-$(CONFIG_PINCTRL_MT8512) += pinctrl-mt8512.o - obj-$(CONFIG_PINCTRL_MT8516) += pinctrl-mt8516.o - obj-$(CONFIG_PINCTRL_MT8518) += pinctrl-mt8518.o ---- /dev/null -+++ b/drivers/pinctrl/mediatek/pinctrl-mt7988.c -@@ -0,0 +1,1274 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (C) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+#include -+#include "pinctrl-mtk-common.h" -+ -+enum MT7988_PINCTRL_REG_PAGE { -+ GPIO_BASE, -+ IOCFG_TR_BASE, -+ IOCFG_BR_BASE, -+ IOCFG_RB_BASE, -+ IOCFG_LB_BASE, -+ IOCFG_TL_BASE, -+}; -+ -+#define MT7988_TYPE0_PIN(_number, _name) \ -+ MTK_TYPED_PIN(_number, _name, DRV_GRP4, IO_TYPE_GRP0) -+ -+#define MT7988_TYPE1_PIN(_number, _name) \ -+ MTK_TYPED_PIN(_number, _name, DRV_GRP4, IO_TYPE_GRP1) -+ -+#define MT7988_TYPE2_PIN(_number, _name) \ -+ MTK_TYPED_PIN(_number, _name, DRV_FIXED, IO_TYPE_GRP2) -+ -+#define PIN_FIELD_GPIO(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ -+ PIN_FIELD_BASE_CALC(_s_pin, _e_pin, GPIO_BASE, _s_addr, _x_addrs, \ -+ _s_bit, _x_bits, 32, 0) -+ -+#define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \ -+ _x_bits) \ -+ PIN_FIELD_BASE_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, \ -+ _s_bit, _x_bits, 32, 0) -+ -+#define PINS_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \ -+ _x_bits) \ -+ PIN_FIELD_BASE_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, \ -+ _s_bit, _x_bits, 32, 1) -+ -+static const struct mtk_pin_field_calc mt7988_pin_mode_range[] = { -+ PIN_FIELD_GPIO(0, 83, 0x300, 0x10, 0, 4), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_dir_range[] = { -+ PIN_FIELD_GPIO(0, 83, 0x0, 0x10, 0, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_di_range[] = { -+ PIN_FIELD_GPIO(0, 83, 0x200, 0x10, 0, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_do_range[] = { -+ PIN_FIELD_GPIO(0, 83, 0x100, 0x10, 0, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0x30, 0x10, 13, 1), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0x30, 0x10, 14, 1), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0x30, 0x10, 11, 1), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0x30, 0x10, 12, 1), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0x30, 0x10, 0, 1), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0x30, 0x10, 9, 1), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0x30, 0x10, 10, 1), -+ -+ PIN_FIELD_BASE(7, 7, IOCFG_LB_BASE, 0x30, 0x10, 8, 1), -+ PIN_FIELD_BASE(8, 8, IOCFG_LB_BASE, 0x30, 0x10, 6, 1), -+ PIN_FIELD_BASE(9, 9, IOCFG_LB_BASE, 0x30, 0x10, 5, 1), -+ PIN_FIELD_BASE(10, 10, IOCFG_LB_BASE, 0x30, 0x10, 3, 1), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0x40, 0x10, 0, 1), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0x40, 0x10, 21, 1), -+ PIN_FIELD_BASE(13, 13, IOCFG_TR_BASE, 0x40, 0x10, 1, 1), -+ PIN_FIELD_BASE(14, 14, IOCFG_TR_BASE, 0x40, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(15, 15, IOCFG_TL_BASE, 0x30, 0x10, 7, 1), -+ PIN_FIELD_BASE(16, 16, IOCFG_TL_BASE, 0x30, 0x10, 8, 1), -+ PIN_FIELD_BASE(17, 17, IOCFG_TL_BASE, 0x30, 0x10, 3, 1), -+ PIN_FIELD_BASE(18, 18, IOCFG_TL_BASE, 0x30, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0x30, 0x10, 7, 1), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0x30, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0x50, 0x10, 17, 1), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0x50, 0x10, 23, 1), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0x50, 0x10, 20, 1), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0x50, 0x10, 19, 1), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0x50, 0x10, 21, 1), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0x50, 0x10, 22, 1), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0x50, 0x10, 18, 1), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0x50, 0x10, 25, 1), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0x50, 0x10, 26, 1), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0x50, 0x10, 27, 1), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0x50, 0x10, 24, 1), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0x50, 0x10, 28, 1), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0x60, 0x10, 0, 1), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0x50, 0x10, 31, 1), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0x50, 0x10, 29, 1), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0x50, 0x10, 30, 1), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0x60, 0x10, 1, 1), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0x50, 0x10, 11, 1), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x50, 0x10, 10, 1), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x50, 0x10, 0, 1), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x50, 0x10, 1, 1), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0x50, 0x10, 9, 1), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0x50, 0x10, 8, 1), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0x50, 0x10, 7, 1), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0x50, 0x10, 6, 1), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0x50, 0x10, 5, 1), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0x50, 0x10, 4, 1), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0x50, 0x10, 3, 1), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0x50, 0x10, 2, 1), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0x50, 0x10, 15, 1), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0x50, 0x10, 12, 1), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0x50, 0x10, 13, 1), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0x50, 0x10, 14, 1), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0x50, 0x10, 16, 1), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0x40, 0x10, 14, 1), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0x40, 0x10, 15, 1), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0x40, 0x10, 13, 1), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0x40, 0x10, 4, 1), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0x40, 0x10, 5, 1), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0x40, 0x10, 6, 1), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0x40, 0x10, 3, 1), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0x40, 0x10, 7, 1), -+ PIN_FIELD_BASE(63, 63, IOCFG_TR_BASE, 0x40, 0x10, 20, 1), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0x40, 0x10, 8, 1), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0x40, 0x10, 9, 1), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0x40, 0x10, 10, 1), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0x40, 0x10, 11, 1), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0x40, 0x10, 12, 1), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0x30, 0x10, 1, 1), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0x30, 0x10, 2, 1), -+ PIN_FIELD_BASE(71, 71, IOCFG_TL_BASE, 0x30, 0x10, 5, 1), -+ PIN_FIELD_BASE(72, 72, IOCFG_TL_BASE, 0x30, 0x10, 6, 1), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0x30, 0x10, 10, 1), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0x30, 0x10, 1, 1), -+ PIN_FIELD_BASE(75, 75, IOCFG_LB_BASE, 0x30, 0x10, 11, 1), -+ PIN_FIELD_BASE(76, 76, IOCFG_LB_BASE, 0x30, 0x10, 9, 1), -+ PIN_FIELD_BASE(77, 77, IOCFG_LB_BASE, 0x30, 0x10, 2, 1), -+ PIN_FIELD_BASE(78, 78, IOCFG_LB_BASE, 0x30, 0x10, 0, 1), -+ PIN_FIELD_BASE(79, 79, IOCFG_LB_BASE, 0x30, 0x10, 12, 1), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x40, 0x10, 18, 1), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0x40, 0x10, 19, 1), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0x40, 0x10, 16, 1), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x40, 0x10, 17, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0xc0, 0x10, 13, 1), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0xc0, 0x10, 14, 1), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0xc0, 0x10, 11, 1), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0xc0, 0x10, 12, 1), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0xc0, 0x10, 0, 1), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0xc0, 0x10, 9, 1), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0xc0, 0x10, 10, 1), -+ -+ PIN_FIELD_BASE(7, 7, IOCFG_LB_BASE, 0xb0, 0x10, 8, 1), -+ PIN_FIELD_BASE(8, 8, IOCFG_LB_BASE, 0xb0, 0x10, 6, 1), -+ PIN_FIELD_BASE(9, 9, IOCFG_LB_BASE, 0xb0, 0x10, 5, 1), -+ PIN_FIELD_BASE(10, 10, IOCFG_LB_BASE, 0xb0, 0x10, 3, 1), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0xe0, 0x10, 0, 1), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0xe0, 0x10, 21, 1), -+ PIN_FIELD_BASE(13, 13, IOCFG_TR_BASE, 0xe0, 0x10, 1, 1), -+ PIN_FIELD_BASE(14, 14, IOCFG_TR_BASE, 0xe0, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(15, 15, IOCFG_TL_BASE, 0xc0, 0x10, 7, 1), -+ PIN_FIELD_BASE(16, 16, IOCFG_TL_BASE, 0xc0, 0x10, 8, 1), -+ PIN_FIELD_BASE(17, 17, IOCFG_TL_BASE, 0xc0, 0x10, 3, 1), -+ PIN_FIELD_BASE(18, 18, IOCFG_TL_BASE, 0xc0, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0xb0, 0x10, 7, 1), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0xb0, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0x140, 0x10, 17, 1), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0x140, 0x10, 23, 1), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0x140, 0x10, 20, 1), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0x140, 0x10, 19, 1), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0x140, 0x10, 21, 1), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0x140, 0x10, 22, 1), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0x140, 0x10, 18, 1), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0x140, 0x10, 25, 1), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0x140, 0x10, 26, 1), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0x140, 0x10, 27, 1), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0x140, 0x10, 24, 1), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0x140, 0x10, 28, 1), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0x150, 0x10, 0, 1), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0x140, 0x10, 31, 1), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0x140, 0x10, 29, 1), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0x140, 0x10, 30, 1), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0x150, 0x10, 1, 1), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0x140, 0x10, 11, 1), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x140, 0x10, 10, 1), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x140, 0x10, 0, 1), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x140, 0x10, 1, 1), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0x140, 0x10, 9, 1), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0x140, 0x10, 8, 1), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0x140, 0x10, 7, 1), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0x140, 0x10, 6, 1), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0x140, 0x10, 5, 1), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0x140, 0x10, 4, 1), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0x140, 0x10, 3, 1), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0x140, 0x10, 2, 1), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0x140, 0x10, 15, 1), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0x140, 0x10, 12, 1), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0x140, 0x10, 13, 1), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0x140, 0x10, 14, 1), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0x140, 0x10, 16, 1), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0xe0, 0x10, 14, 1), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0xe0, 0x10, 15, 1), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0xe0, 0x10, 13, 1), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0xe0, 0x10, 4, 1), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0xe0, 0x10, 5, 1), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0xe0, 0x10, 6, 1), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0xe0, 0x10, 3, 1), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0xe0, 0x10, 7, 1), -+ PIN_FIELD_BASE(63, 63, IOCFG_TR_BASE, 0xe0, 0x10, 20, 1), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0xe0, 0x10, 8, 1), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0xe0, 0x10, 9, 1), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0xe0, 0x10, 10, 1), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0xe0, 0x10, 11, 1), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0xe0, 0x10, 12, 1), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0xc0, 0x10, 1, 1), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0xc0, 0x10, 2, 1), -+ PIN_FIELD_BASE(71, 71, IOCFG_TL_BASE, 0xc0, 0x10, 5, 1), -+ PIN_FIELD_BASE(72, 72, IOCFG_TL_BASE, 0xc0, 0x10, 6, 1), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0xb0, 0x10, 10, 1), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0xb0, 0x10, 1, 1), -+ PIN_FIELD_BASE(75, 75, IOCFG_LB_BASE, 0xb0, 0x10, 11, 1), -+ PIN_FIELD_BASE(76, 76, IOCFG_LB_BASE, 0xb0, 0x10, 9, 1), -+ PIN_FIELD_BASE(77, 77, IOCFG_LB_BASE, 0xb0, 0x10, 2, 1), -+ PIN_FIELD_BASE(78, 78, IOCFG_LB_BASE, 0xb0, 0x10, 0, 1), -+ PIN_FIELD_BASE(79, 79, IOCFG_LB_BASE, 0xb0, 0x10, 12, 1), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0xe0, 0x10, 18, 1), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0xe0, 0x10, 19, 1), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0xe0, 0x10, 16, 1), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0xe0, 0x10, 17, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_pu_range[] = { -+ PIN_FIELD_BASE(7, 7, IOCFG_LB_BASE, 0x60, 0x10, 5, 1), -+ PIN_FIELD_BASE(8, 8, IOCFG_LB_BASE, 0x60, 0x10, 4, 1), -+ PIN_FIELD_BASE(9, 9, IOCFG_LB_BASE, 0x60, 0x10, 3, 1), -+ PIN_FIELD_BASE(10, 10, IOCFG_LB_BASE, 0x60, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(13, 13, IOCFG_TR_BASE, 0x70, 0x10, 0, 1), -+ PIN_FIELD_BASE(14, 14, IOCFG_TR_BASE, 0x70, 0x10, 1, 1), -+ PIN_FIELD_BASE(63, 63, IOCFG_TR_BASE, 0x70, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(75, 75, IOCFG_LB_BASE, 0x60, 0x10, 7, 1), -+ PIN_FIELD_BASE(76, 76, IOCFG_LB_BASE, 0x60, 0x10, 6, 1), -+ PIN_FIELD_BASE(77, 77, IOCFG_LB_BASE, 0x60, 0x10, 1, 1), -+ PIN_FIELD_BASE(78, 78, IOCFG_LB_BASE, 0x60, 0x10, 0, 1), -+ PIN_FIELD_BASE(79, 79, IOCFG_LB_BASE, 0x60, 0x10, 8, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_pd_range[] = { -+ PIN_FIELD_BASE(7, 7, IOCFG_LB_BASE, 0x40, 0x10, 5, 1), -+ PIN_FIELD_BASE(8, 8, IOCFG_LB_BASE, 0x40, 0x10, 4, 1), -+ PIN_FIELD_BASE(9, 9, IOCFG_LB_BASE, 0x40, 0x10, 3, 1), -+ PIN_FIELD_BASE(10, 10, IOCFG_LB_BASE, 0x40, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(13, 13, IOCFG_TR_BASE, 0x50, 0x10, 0, 1), -+ PIN_FIELD_BASE(14, 14, IOCFG_TR_BASE, 0x50, 0x10, 1, 1), -+ -+ PIN_FIELD_BASE(15, 15, IOCFG_TL_BASE, 0x40, 0x10, 4, 1), -+ PIN_FIELD_BASE(16, 16, IOCFG_TL_BASE, 0x40, 0x10, 5, 1), -+ PIN_FIELD_BASE(17, 17, IOCFG_TL_BASE, 0x40, 0x10, 0, 1), -+ PIN_FIELD_BASE(18, 18, IOCFG_TL_BASE, 0x40, 0x10, 1, 1), -+ -+ PIN_FIELD_BASE(63, 63, IOCFG_TR_BASE, 0x50, 0x10, 2, 1), -+ PIN_FIELD_BASE(71, 71, IOCFG_TL_BASE, 0x40, 0x10, 2, 1), -+ PIN_FIELD_BASE(72, 72, IOCFG_TL_BASE, 0x40, 0x10, 3, 1), -+ -+ PIN_FIELD_BASE(75, 75, IOCFG_LB_BASE, 0x40, 0x10, 7, 1), -+ PIN_FIELD_BASE(76, 76, IOCFG_LB_BASE, 0x40, 0x10, 6, 1), -+ PIN_FIELD_BASE(77, 77, IOCFG_LB_BASE, 0x40, 0x10, 1, 1), -+ PIN_FIELD_BASE(78, 78, IOCFG_LB_BASE, 0x40, 0x10, 0, 1), -+ PIN_FIELD_BASE(79, 79, IOCFG_LB_BASE, 0x40, 0x10, 8, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0x00, 0x10, 21, 3), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0x00, 0x10, 24, 3), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0x00, 0x10, 15, 3), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0x00, 0x10, 18, 3), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0x00, 0x10, 0, 3), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0x00, 0x10, 9, 3), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0x00, 0x10, 12, 3), -+ -+ PIN_FIELD_BASE(7, 7, IOCFG_LB_BASE, 0x00, 0x10, 24, 3), -+ PIN_FIELD_BASE(8, 8, IOCFG_LB_BASE, 0x00, 0x10, 28, 3), -+ PIN_FIELD_BASE(9, 9, IOCFG_LB_BASE, 0x00, 0x10, 15, 3), -+ PIN_FIELD_BASE(10, 10, IOCFG_LB_BASE, 0x00, 0x10, 9, 3), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0x00, 0x10, 0, 3), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0x20, 0x10, 3, 3), -+ PIN_FIELD_BASE(13, 13, IOCFG_TR_BASE, 0x00, 0x10, 3, 3), -+ PIN_FIELD_BASE(14, 14, IOCFG_TR_BASE, 0x00, 0x10, 6, 3), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0x00, 0x10, 21, 3), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0x00, 0x10, 12, 3), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0x10, 0x10, 21, 3), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0x20, 0x10, 9, 3), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0x20, 0x10, 0, 3), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0x10, 0x10, 27, 3), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0x20, 0x10, 3, 3), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0x20, 0x10, 6, 3), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0x10, 0x10, 24, 3), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0x20, 0x10, 15, 3), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0x20, 0x10, 18, 3), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0x20, 0x10, 21, 3), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0x20, 0x10, 12, 3), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0x20, 0x10, 24, 3), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0x30, 0x10, 6, 3), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0x30, 0x10, 3, 3), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0x20, 0x10, 27, 3), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0x30, 0x10, 0, 3), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0x30, 0x10, 9, 3), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0x10, 0x10, 3, 3), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x10, 0x10, 0, 3), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x00, 0x10, 0, 3), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x00, 0x10, 3, 3), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0x00, 0x10, 27, 3), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0x00, 0x10, 24, 3), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0x00, 0x10, 21, 3), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0x00, 0x10, 18, 3), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0x00, 0x10, 15, 3), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0x00, 0x10, 12, 3), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0x00, 0x10, 9, 3), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0x00, 0x10, 6, 3), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0x10, 0x10, 15, 3), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0x10, 0x10, 6, 3), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0x10, 0x10, 9, 3), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0x10, 0x10, 12, 3), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0x10, 0x10, 18, 3), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0x10, 0x10, 12, 3), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0x10, 0x10, 15, 3), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0x10, 0x10, 9, 3), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0x00, 0x10, 12, 3), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0x00, 0x10, 15, 3), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0x00, 0x10, 18, 3), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0x00, 0x10, 9, 3), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0x00, 0x10, 21, 3), -+ PIN_FIELD_BASE(63, 63, IOCFG_TR_BASE, 0x20, 0x10, 0, 3), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0x00, 0x10, 24, 3), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0x00, 0x10, 27, 3), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0x10, 0x10, 0, 3), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0x10, 0x10, 3, 3), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0x10, 0x10, 6, 3), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0x00, 0x10, 3, 3), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0x00, 0x10, 6, 3), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0x10, 0x10, 0, 3), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0x00, 0x10, 3, 3), -+ PIN_FIELD_BASE(75, 75, IOCFG_LB_BASE, 0x10, 0x10, 3, 3), -+ PIN_FIELD_BASE(76, 76, IOCFG_LB_BASE, 0x00, 0x10, 27, 3), -+ PIN_FIELD_BASE(77, 77, IOCFG_LB_BASE, 0x00, 0x10, 6, 3), -+ PIN_FIELD_BASE(78, 78, IOCFG_LB_BASE, 0x00, 0x10, 0, 3), -+ PIN_FIELD_BASE(79, 79, IOCFG_LB_BASE, 0x10, 0x10, 6, 3), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x10, 0x10, 24, 3), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0x10, 0x10, 27, 3), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0x10, 0x10, 18, 3), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x10, 0x10, 21, 3), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_pupd_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0x50, 0x10, 7, 1), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0x50, 0x10, 8, 1), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0x50, 0x10, 5, 1), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0x50, 0x10, 6, 1), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0x50, 0x10, 0, 1), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0x50, 0x10, 3, 1), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0x50, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0x60, 0x10, 0, 1), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0x60, 0x10, 18, 1), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0x50, 0x10, 2, 1), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0x50, 0x10, 1, 1), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0x70, 0x10, 17, 1), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0x70, 0x10, 23, 1), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0x70, 0x10, 20, 1), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0x70, 0x10, 19, 1), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0x70, 0x10, 21, 1), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0x70, 0x10, 22, 1), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0x70, 0x10, 18, 1), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0x70, 0x10, 25, 1), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0x70, 0x10, 26, 1), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0x70, 0x10, 27, 1), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0x70, 0x10, 24, 1), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0x70, 0x10, 28, 1), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0x80, 0x10, 0, 1), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0x70, 0x10, 31, 1), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0x70, 0x10, 29, 1), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0x70, 0x10, 30, 1), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0x80, 0x10, 1, 1), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0x70, 0x10, 11, 1), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x70, 0x10, 10, 1), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x70, 0x10, 0, 1), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x70, 0x10, 1, 1), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0x70, 0x10, 9, 1), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0x70, 0x10, 8, 1), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0x70, 0x10, 7, 1), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0x70, 0x10, 6, 1), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0x70, 0x10, 5, 1), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0x70, 0x10, 4, 1), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0x70, 0x10, 3, 1), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0x70, 0x10, 2, 1), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0x70, 0x10, 15, 1), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0x70, 0x10, 12, 1), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0x70, 0x10, 13, 1), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0x70, 0x10, 14, 1), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0x70, 0x10, 16, 1), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0x60, 0x10, 12, 1), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0x60, 0x10, 13, 1), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0x60, 0x10, 11, 1), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0x60, 0x10, 2, 1), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0x60, 0x10, 3, 1), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0x60, 0x10, 4, 1), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0x60, 0x10, 1, 1), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0x60, 0x10, 5, 1), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0x60, 0x10, 6, 1), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0x60, 0x10, 7, 1), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0x60, 0x10, 8, 1), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0x60, 0x10, 9, 1), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0x60, 0x10, 10, 1), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0x50, 0x10, 1, 1), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0x50, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0x50, 0x10, 3, 1), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0x50, 0x10, 0, 1), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x60, 0x10, 16, 1), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0x60, 0x10, 17, 1), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0x60, 0x10, 14, 1), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x60, 0x10, 15, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_r0_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0x60, 0x10, 7, 1), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0x60, 0x10, 8, 1), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0x60, 0x10, 5, 1), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0x60, 0x10, 6, 1), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0x60, 0x10, 0, 1), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0x60, 0x10, 3, 1), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0x60, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0x80, 0x10, 0, 1), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0x80, 0x10, 18, 1), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0x70, 0x10, 2, 1), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0x70, 0x10, 1, 1), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0x90, 0x10, 17, 1), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0x90, 0x10, 23, 1), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0x90, 0x10, 20, 1), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0x90, 0x10, 19, 1), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0x90, 0x10, 21, 1), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0x90, 0x10, 22, 1), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0x90, 0x10, 18, 1), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0x90, 0x10, 25, 1), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0x90, 0x10, 26, 1), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0x90, 0x10, 27, 1), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0x90, 0x10, 24, 1), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0x90, 0x10, 28, 1), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0xa0, 0x10, 0, 1), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0x90, 0x10, 31, 1), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0x90, 0x10, 29, 1), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0x90, 0x10, 30, 1), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0xa0, 0x10, 1, 1), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0x90, 0x10, 11, 1), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x90, 0x10, 10, 1), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x90, 0x10, 0, 1), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x90, 0x10, 1, 1), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0x90, 0x10, 9, 1), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0x90, 0x10, 8, 1), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0x90, 0x10, 7, 1), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0x90, 0x10, 6, 1), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0x90, 0x10, 5, 1), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0x90, 0x10, 4, 1), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0x90, 0x10, 3, 1), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0x90, 0x10, 2, 1), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0x90, 0x10, 15, 1), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0x90, 0x10, 12, 1), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0x90, 0x10, 13, 1), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0x90, 0x10, 14, 1), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0x90, 0x10, 16, 1), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0x80, 0x10, 12, 1), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0x80, 0x10, 13, 1), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0x80, 0x10, 11, 1), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0x80, 0x10, 2, 1), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0x80, 0x10, 3, 1), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0x80, 0x10, 4, 1), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0x80, 0x10, 1, 1), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0x80, 0x10, 5, 1), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0x80, 0x10, 6, 1), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0x80, 0x10, 7, 1), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0x80, 0x10, 8, 1), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0x80, 0x10, 9, 1), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0x80, 0x10, 10, 1), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0x60, 0x10, 1, 1), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0x60, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0x70, 0x10, 3, 1), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0x70, 0x10, 0, 1), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x80, 0x10, 16, 1), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0x80, 0x10, 17, 1), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0x80, 0x10, 14, 1), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x80, 0x10, 15, 1), -+}; -+ -+static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = { -+ PIN_FIELD_BASE(0, 0, IOCFG_TL_BASE, 0x70, 0x10, 7, 1), -+ PIN_FIELD_BASE(1, 1, IOCFG_TL_BASE, 0x70, 0x10, 8, 1), -+ PIN_FIELD_BASE(2, 2, IOCFG_TL_BASE, 0x70, 0x10, 5, 1), -+ PIN_FIELD_BASE(3, 3, IOCFG_TL_BASE, 0x70, 0x10, 6, 1), -+ PIN_FIELD_BASE(4, 4, IOCFG_TL_BASE, 0x70, 0x10, 0, 1), -+ PIN_FIELD_BASE(5, 5, IOCFG_TL_BASE, 0x70, 0x10, 3, 1), -+ PIN_FIELD_BASE(6, 6, IOCFG_TL_BASE, 0x70, 0x10, 4, 1), -+ -+ PIN_FIELD_BASE(11, 11, IOCFG_TR_BASE, 0x90, 0x10, 0, 1), -+ PIN_FIELD_BASE(12, 12, IOCFG_TR_BASE, 0x90, 0x10, 18, 1), -+ -+ PIN_FIELD_BASE(19, 19, IOCFG_LB_BASE, 0x80, 0x10, 2, 1), -+ PIN_FIELD_BASE(20, 20, IOCFG_LB_BASE, 0x80, 0x10, 1, 1), -+ -+ PIN_FIELD_BASE(21, 21, IOCFG_RB_BASE, 0xb0, 0x10, 17, 1), -+ PIN_FIELD_BASE(22, 22, IOCFG_RB_BASE, 0xb0, 0x10, 23, 1), -+ PIN_FIELD_BASE(23, 23, IOCFG_RB_BASE, 0xb0, 0x10, 20, 1), -+ PIN_FIELD_BASE(24, 24, IOCFG_RB_BASE, 0xb0, 0x10, 19, 1), -+ PIN_FIELD_BASE(25, 25, IOCFG_RB_BASE, 0xb0, 0x10, 21, 1), -+ PIN_FIELD_BASE(26, 26, IOCFG_RB_BASE, 0xb0, 0x10, 22, 1), -+ PIN_FIELD_BASE(27, 27, IOCFG_RB_BASE, 0xb0, 0x10, 18, 1), -+ PIN_FIELD_BASE(28, 28, IOCFG_RB_BASE, 0xb0, 0x10, 25, 1), -+ PIN_FIELD_BASE(29, 29, IOCFG_RB_BASE, 0xb0, 0x10, 26, 1), -+ PIN_FIELD_BASE(30, 30, IOCFG_RB_BASE, 0xb0, 0x10, 27, 1), -+ PIN_FIELD_BASE(31, 31, IOCFG_RB_BASE, 0xb0, 0x10, 24, 1), -+ PIN_FIELD_BASE(32, 32, IOCFG_RB_BASE, 0xb0, 0x10, 28, 1), -+ PIN_FIELD_BASE(33, 33, IOCFG_RB_BASE, 0xc0, 0x10, 0, 1), -+ PIN_FIELD_BASE(34, 34, IOCFG_RB_BASE, 0xb0, 0x10, 31, 1), -+ PIN_FIELD_BASE(35, 35, IOCFG_RB_BASE, 0xb0, 0x10, 29, 1), -+ PIN_FIELD_BASE(36, 36, IOCFG_RB_BASE, 0xb0, 0x10, 30, 1), -+ PIN_FIELD_BASE(37, 37, IOCFG_RB_BASE, 0xc0, 0x10, 1, 1), -+ PIN_FIELD_BASE(38, 38, IOCFG_RB_BASE, 0xb0, 0x10, 11, 1), -+ PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0xb0, 0x10, 10, 1), -+ PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0xb0, 0x10, 0, 1), -+ PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0xb0, 0x10, 1, 1), -+ PIN_FIELD_BASE(42, 42, IOCFG_RB_BASE, 0xb0, 0x10, 9, 1), -+ PIN_FIELD_BASE(43, 43, IOCFG_RB_BASE, 0xb0, 0x10, 8, 1), -+ PIN_FIELD_BASE(44, 44, IOCFG_RB_BASE, 0xb0, 0x10, 7, 1), -+ PIN_FIELD_BASE(45, 45, IOCFG_RB_BASE, 0xb0, 0x10, 6, 1), -+ PIN_FIELD_BASE(46, 46, IOCFG_RB_BASE, 0xb0, 0x10, 5, 1), -+ PIN_FIELD_BASE(47, 47, IOCFG_RB_BASE, 0xb0, 0x10, 4, 1), -+ PIN_FIELD_BASE(48, 48, IOCFG_RB_BASE, 0xb0, 0x10, 3, 1), -+ PIN_FIELD_BASE(49, 49, IOCFG_RB_BASE, 0xb0, 0x10, 2, 1), -+ PIN_FIELD_BASE(50, 50, IOCFG_RB_BASE, 0xb0, 0x10, 15, 1), -+ PIN_FIELD_BASE(51, 51, IOCFG_RB_BASE, 0xb0, 0x10, 12, 1), -+ PIN_FIELD_BASE(52, 52, IOCFG_RB_BASE, 0xb0, 0x10, 13, 1), -+ PIN_FIELD_BASE(53, 53, IOCFG_RB_BASE, 0xb0, 0x10, 14, 1), -+ PIN_FIELD_BASE(54, 54, IOCFG_RB_BASE, 0xb0, 0x10, 16, 1), -+ -+ PIN_FIELD_BASE(55, 55, IOCFG_TR_BASE, 0x90, 0x10, 12, 1), -+ PIN_FIELD_BASE(56, 56, IOCFG_TR_BASE, 0x90, 0x10, 13, 1), -+ PIN_FIELD_BASE(57, 57, IOCFG_TR_BASE, 0x90, 0x10, 11, 1), -+ PIN_FIELD_BASE(58, 58, IOCFG_TR_BASE, 0x90, 0x10, 2, 1), -+ PIN_FIELD_BASE(59, 59, IOCFG_TR_BASE, 0x90, 0x10, 3, 1), -+ PIN_FIELD_BASE(60, 60, IOCFG_TR_BASE, 0x90, 0x10, 4, 1), -+ PIN_FIELD_BASE(61, 61, IOCFG_TR_BASE, 0x90, 0x10, 1, 1), -+ PIN_FIELD_BASE(62, 62, IOCFG_TR_BASE, 0x90, 0x10, 5, 1), -+ PIN_FIELD_BASE(64, 64, IOCFG_TR_BASE, 0x90, 0x10, 6, 1), -+ PIN_FIELD_BASE(65, 65, IOCFG_TR_BASE, 0x90, 0x10, 7, 1), -+ PIN_FIELD_BASE(66, 66, IOCFG_TR_BASE, 0x90, 0x10, 8, 1), -+ PIN_FIELD_BASE(67, 67, IOCFG_TR_BASE, 0x90, 0x10, 9, 1), -+ PIN_FIELD_BASE(68, 68, IOCFG_TR_BASE, 0x90, 0x10, 10, 1), -+ -+ PIN_FIELD_BASE(69, 69, IOCFG_TL_BASE, 0x70, 0x10, 1, 1), -+ PIN_FIELD_BASE(70, 70, IOCFG_TL_BASE, 0x70, 0x10, 2, 1), -+ -+ PIN_FIELD_BASE(73, 73, IOCFG_LB_BASE, 0x80, 0x10, 3, 1), -+ PIN_FIELD_BASE(74, 74, IOCFG_LB_BASE, 0x80, 0x10, 0, 1), -+ -+ PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x90, 0x10, 16, 1), -+ PIN_FIELD_BASE(81, 81, IOCFG_TR_BASE, 0x90, 0x10, 17, 1), -+ PIN_FIELD_BASE(82, 82, IOCFG_TR_BASE, 0x90, 0x10, 14, 1), -+ PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x90, 0x10, 15, 1), -+}; -+ -+static const struct mtk_pin_reg_calc mt7988_reg_cals[] = { -+ [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7988_pin_mode_range), -+ [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7988_pin_dir_range), -+ [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7988_pin_di_range), -+ [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7988_pin_do_range), -+ [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7988_pin_smt_range), -+ [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7988_pin_ies_range), -+ [PINCTRL_PIN_REG_PU] = MTK_RANGE(mt7988_pin_pu_range), -+ [PINCTRL_PIN_REG_PD] = MTK_RANGE(mt7988_pin_pd_range), -+ [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7988_pin_drv_range), -+ [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7988_pin_pupd_range), -+ [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7988_pin_r0_range), -+ [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7988_pin_r1_range), -+}; -+ -+static const struct mtk_pin_desc mt7988_pins[] = { -+ MT7988_TYPE0_PIN(0, "UART2_RXD"), -+ MT7988_TYPE0_PIN(1, "UART2_TXD"), -+ MT7988_TYPE0_PIN(2, "UART2_CTS"), -+ MT7988_TYPE0_PIN(3, "UART2_RTS"), -+ MT7988_TYPE0_PIN(4, "GPIO_A"), -+ MT7988_TYPE0_PIN(5, "SMI_0_MDC"), -+ MT7988_TYPE0_PIN(6, "SMI_0_MDIO"), -+ MT7988_TYPE1_PIN(7, "PCIE30_2L_0_WAKE_N"), -+ MT7988_TYPE1_PIN(8, "PCIE30_2L_0_CLKREQ_N"), -+ MT7988_TYPE1_PIN(9, "PCIE30_1L_1_WAKE_N"), -+ MT7988_TYPE1_PIN(10, "PCIE30_1L_1_CLKREQ_N"), -+ MT7988_TYPE0_PIN(11, "GPIO_P"), -+ MT7988_TYPE0_PIN(12, "WATCHDOG"), -+ MT7988_TYPE1_PIN(13, "GPIO_RESET"), -+ MT7988_TYPE1_PIN(14, "GPIO_WPS"), -+ MT7988_TYPE2_PIN(15, "PMIC_I2C_SCL"), -+ MT7988_TYPE2_PIN(16, "PMIC_I2C_SDA"), -+ MT7988_TYPE2_PIN(17, "I2C_1_SCL"), -+ MT7988_TYPE2_PIN(18, "I2C_1_SDA"), -+ MT7988_TYPE0_PIN(19, "PCIE30_2L_0_PRESET_N"), -+ MT7988_TYPE0_PIN(20, "PCIE30_1L_1_PRESET_N"), -+ MT7988_TYPE0_PIN(21, "PWMD1"), -+ MT7988_TYPE0_PIN(22, "SPI0_WP"), -+ MT7988_TYPE0_PIN(23, "SPI0_HOLD"), -+ MT7988_TYPE0_PIN(24, "SPI0_CSB"), -+ MT7988_TYPE0_PIN(25, "SPI0_MISO"), -+ MT7988_TYPE0_PIN(26, "SPI0_MOSI"), -+ MT7988_TYPE0_PIN(27, "SPI0_CLK"), -+ MT7988_TYPE0_PIN(28, "SPI1_CSB"), -+ MT7988_TYPE0_PIN(29, "SPI1_MISO"), -+ MT7988_TYPE0_PIN(30, "SPI1_MOSI"), -+ MT7988_TYPE0_PIN(31, "SPI1_CLK"), -+ MT7988_TYPE0_PIN(32, "SPI2_CLK"), -+ MT7988_TYPE0_PIN(33, "SPI2_MOSI"), -+ MT7988_TYPE0_PIN(34, "SPI2_MISO"), -+ MT7988_TYPE0_PIN(35, "SPI2_CSB"), -+ MT7988_TYPE0_PIN(36, "SPI2_HOLD"), -+ MT7988_TYPE0_PIN(37, "SPI2_WP"), -+ MT7988_TYPE0_PIN(38, "EMMC_RSTB"), -+ MT7988_TYPE0_PIN(39, "EMMC_DSL"), -+ MT7988_TYPE0_PIN(40, "EMMC_CK"), -+ MT7988_TYPE0_PIN(41, "EMMC_CMD"), -+ MT7988_TYPE0_PIN(42, "EMMC_DATA_7"), -+ MT7988_TYPE0_PIN(43, "EMMC_DATA_6"), -+ MT7988_TYPE0_PIN(44, "EMMC_DATA_5"), -+ MT7988_TYPE0_PIN(45, "EMMC_DATA_4"), -+ MT7988_TYPE0_PIN(46, "EMMC_DATA_3"), -+ MT7988_TYPE0_PIN(47, "EMMC_DATA_2"), -+ MT7988_TYPE0_PIN(48, "EMMC_DATA_1"), -+ MT7988_TYPE0_PIN(49, "EMMC_DATA_0"), -+ MT7988_TYPE0_PIN(50, "PCM_FS_I2S_LRCK"), -+ MT7988_TYPE0_PIN(51, "PCM_CLK_I2S_BCLK"), -+ MT7988_TYPE0_PIN(52, "PCM_DRX_I2S_DIN"), -+ MT7988_TYPE0_PIN(53, "PCM_DTX_I2S_DOUT"), -+ MT7988_TYPE0_PIN(54, "PCM_MCK_I2S_MCLK"), -+ MT7988_TYPE0_PIN(55, "UART0_RXD"), -+ MT7988_TYPE0_PIN(56, "UART0_TXD"), -+ MT7988_TYPE0_PIN(57, "PWMD0"), -+ MT7988_TYPE0_PIN(58, "JTAG_JTDI"), -+ MT7988_TYPE0_PIN(59, "JTAG_JTDO"), -+ MT7988_TYPE0_PIN(60, "JTAG_JTMS"), -+ MT7988_TYPE0_PIN(61, "JTAG_JTCLK"), -+ MT7988_TYPE0_PIN(62, "JTAG_JTRST_N"), -+ MT7988_TYPE1_PIN(63, "USB_DRV_VBUS_P1"), -+ MT7988_TYPE0_PIN(64, "LED_A"), -+ MT7988_TYPE0_PIN(65, "LED_B"), -+ MT7988_TYPE0_PIN(66, "LED_C"), -+ MT7988_TYPE0_PIN(67, "LED_D"), -+ MT7988_TYPE0_PIN(68, "LED_E"), -+ MT7988_TYPE0_PIN(69, "GPIO_B"), -+ MT7988_TYPE0_PIN(70, "GPIO_C"), -+ MT7988_TYPE2_PIN(71, "I2C_2_SCL"), -+ MT7988_TYPE2_PIN(72, "I2C_2_SDA"), -+ MT7988_TYPE0_PIN(73, "PCIE30_2L_1_PRESET_N"), -+ MT7988_TYPE0_PIN(74, "PCIE30_1L_0_PRESET_N"), -+ MT7988_TYPE1_PIN(75, "PCIE30_2L_1_WAKE_N"), -+ MT7988_TYPE1_PIN(76, "PCIE30_2L_1_CLKREQ_N"), -+ MT7988_TYPE1_PIN(77, "PCIE30_1L_0_WAKE_N"), -+ MT7988_TYPE1_PIN(78, "PCIE30_1L_0_CLKREQ_N"), -+ MT7988_TYPE1_PIN(79, "USB_DRV_VBUS_P0"), -+ MT7988_TYPE0_PIN(80, "UART1_RXD"), -+ MT7988_TYPE0_PIN(81, "UART1_TXD"), -+ MT7988_TYPE0_PIN(82, "UART1_CTS"), -+ MT7988_TYPE0_PIN(83, "UART1_RTS"), -+}; -+ -+/* jtag */ -+static const int mt7988_tops_jtag0_0_pins[] = { 0, 1, 2, 3, 4 }; -+static const int mt7988_tops_jtag0_0_funcs[] = { 2, 2, 2, 2, 2 }; -+ -+static const int mt7988_wo0_jtag_pins[] = { 50, 51, 52, 53, 54 }; -+static const int mt7988_wo0_jtag_funcs[] = { 3, 3, 3, 3, 3 }; -+ -+static const int mt7988_wo1_jtag_pins[] = { 50, 51, 52, 53, 54 }; -+static const int mt7988_wo1_jtag_funcs[] = { 4, 4, 4, 4, 4 }; -+ -+static const int mt7988_wo2_jtag_pins[] = { 50, 51, 52, 53, 54 }; -+static const int mt7988_wo2_jtag_funcs[] = { 5, 5, 5, 5, 5 }; -+ -+static const int mt7988_jtag_pins[] = { 58, 59, 60, 61, 62 }; -+static const int mt7988_jtag_funcs[] = { 1, 1, 1, 1, 1 }; -+ -+static const int mt7988_tops_jtag0_1_pins[] = { 58, 59, 60, 61, 62 }; -+static const int mt7988_tops_jtag0_1_funcs[] = { 4, 4, 4, 4, 4 }; -+ -+/* int_usxgmii */ -+static const int mt7988_int_usxgmii_pins[] = { 2, 3 }; -+static const int mt7988_int_usxgmii_funcs[] = { 3, 3 }; -+ -+/* pwm */ -+static const int mt7988_pwm0_pins[] = { 57 }; -+static const int mt7988_pwm0_funcs[] = { 1 }; -+ -+static const int mt7988_pwm1_pins[] = { 21 }; -+static const int mt7988_pwm1_funcs[] = { 1 }; -+ -+static const int mt7988_pwm2_pins[] = { 80 }; -+static const int mt7988_pwm2_funcs[] = { 2 }; -+ -+static const int mt7988_pwm3_pins[] = { 81 }; -+static const int mt7988_pwm3_funcs[] = { 2 }; -+ -+static const int mt7988_pwm4_pins[] = { 82 }; -+static const int mt7988_pwm4_funcs[] = { 2 }; -+ -+static const int mt7988_pwm5_pins[] = { 83 }; -+static const int mt7988_pwm5_funcs[] = { 2 }; -+ -+static const int mt7988_pwm6_pins[] = { 69 }; -+static const int mt7988_pwm6_funcs[] = { 3 }; -+ -+static const int mt7988_pwm7_pins[] = { 70 }; -+static const int mt7988_pwm7_funcs[] = { 3 }; -+ -+/* dfd */ -+static const int mt7988_dfd_pins[] = { 0, 1, 2, 3, 4 }; -+static const int mt7988_dfd_funcs[] = { 4, 4, 4, 4, 4 }; -+ -+/* i2c */ -+static const int mt7988_xfi_phy0_i2c0_pins[] = { 0, 1 }; -+static const int mt7988_xfi_phy0_i2c0_funcs[] = { 5, 5 }; -+ -+static const int mt7988_xfi_phy1_i2c0_pins[] = { 0, 1 }; -+static const int mt7988_xfi_phy1_i2c0_funcs[] = { 6, 6 }; -+ -+static const int mt7988_xfi_phy_pll_i2c0_pins[] = { 3, 4 }; -+static const int mt7988_xfi_phy_pll_i2c0_funcs[] = { 5, 5 }; -+ -+static const int mt7988_xfi_phy_pll_i2c1_pins[] = { 3, 4 }; -+static const int mt7988_xfi_phy_pll_i2c1_funcs[] = { 6, 6 }; -+ -+static const int mt7988_i2c0_0_pins[] = { 5, 6 }; -+static const int mt7988_i2c0_0_funcs[] = { 2, 2 }; -+ -+static const int mt7988_i2c1_sfp_pins[] = { 5, 6 }; -+static const int mt7988_i2c1_sfp_funcs[] = { 4, 4 }; -+ -+static const int mt7988_xfi_pextp_phy0_i2c_pins[] = { 5, 6 }; -+static const int mt7988_xfi_pextp_phy0_i2c_funcs[] = { 5, 5 }; -+ -+static const int mt7988_xfi_pextp_phy1_i2c_pins[] = { 5, 6 }; -+static const int mt7988_xfi_pextp_phy1_i2c_funcs[] = { 6, 6 }; -+ -+static const int mt7988_i2c0_1_pins[] = { 15, 16 }; -+static const int mt7988_i2c0_1_funcs[] = { 1, 1 }; -+ -+static const int mt7988_u30_phy_i2c0_pins[] = { 15, 16 }; -+static const int mt7988_u30_phy_i2c0_funcs[] = { 2, 2 }; -+ -+static const int mt7988_u32_phy_i2c0_pins[] = { 15, 16 }; -+static const int mt7988_u32_phy_i2c0_funcs[] = { 3, 3 }; -+ -+static const int mt7988_xfi_phy0_i2c1_pins[] = { 15, 16 }; -+static const int mt7988_xfi_phy0_i2c1_funcs[] = { 5, 5 }; -+ -+static const int mt7988_xfi_phy1_i2c1_pins[] = { 15, 16 }; -+static const int mt7988_xfi_phy1_i2c1_funcs[] = { 6, 6 }; -+ -+static const int mt7988_xfi_phy_pll_i2c2_pins[] = { 15, 16 }; -+static const int mt7988_xfi_phy_pll_i2c2_funcs[] = { 7, 7 }; -+ -+static const int mt7988_i2c1_0_pins[] = { 17, 18 }; -+static const int mt7988_i2c1_0_funcs[] = { 1, 1 }; -+ -+static const int mt7988_u30_phy_i2c1_pins[] = { 17, 18 }; -+static const int mt7988_u30_phy_i2c1_funcs[] = { 2, 2 }; -+ -+static const int mt7988_u32_phy_i2c1_pins[] = { 17, 18 }; -+static const int mt7988_u32_phy_i2c1_funcs[] = { 3, 3 }; -+ -+static const int mt7988_xfi_phy_pll_i2c3_pins[] = { 17, 18 }; -+static const int mt7988_xfi_phy_pll_i2c3_funcs[] = { 4, 4 }; -+ -+static const int mt7988_sgmii0_i2c_pins[] = { 17, 18 }; -+static const int mt7988_sgmii0_i2c_funcs[] = { 5, 5 }; -+ -+static const int mt7988_sgmii1_i2c_pins[] = { 17, 18 }; -+static const int mt7988_sgmii1_i2c_funcs[] = { 6, 6 }; -+ -+static const int mt7988_i2c1_2_pins[] = { 69, 70 }; -+static const int mt7988_i2c1_2_funcs[] = { 2, 2 }; -+ -+static const int mt7988_i2c2_0_pins[] = { 69, 70 }; -+static const int mt7988_i2c2_0_funcs[] = { 4, 4 }; -+ -+static const int mt7988_i2c2_1_pins[] = { 71, 72 }; -+static const int mt7988_i2c2_1_funcs[] = { 1, 1 }; -+ -+/* eth */ -+static const int mt7988_mdc_mdio0_pins[] = { 5, 6 }; -+static const int mt7988_mdc_mdio0_funcs[] = { 1, 1 }; -+ -+static const int mt7988_2p5g_ext_mdio_pins[] = { 28, 29 }; -+static const int mt7988_2p5g_ext_mdio_funcs[] = { 6, 6 }; -+ -+static const int mt7988_gbe_ext_mdio_pins[] = { 30, 31 }; -+static const int mt7988_gbe_ext_mdio_funcs[] = { 6, 6 }; -+ -+static const int mt7988_mdc_mdio1_pins[] = { 69, 70 }; -+static const int mt7988_mdc_mdio1_funcs[] = { 1, 1 }; -+ -+/* pcie */ -+static const int mt7988_pcie_wake_n0_0_pins[] = { 7 }; -+static const int mt7988_pcie_wake_n0_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n0_0_pins[] = { 8 }; -+static const int mt7988_pcie_clk_req_n0_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_wake_n3_0_pins[] = { 9 }; -+static const int mt7988_pcie_wake_n3_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n3_pins[] = { 10 }; -+static const int mt7988_pcie_clk_req_n3_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n0_1_pins[] = { 10 }; -+static const int mt7988_pcie_clk_req_n0_1_funcs[] = { 2 }; -+ -+static const int mt7988_pcie_p0_phy_i2c_pins[] = { 7, 8 }; -+static const int mt7988_pcie_p0_phy_i2c_funcs[] = { 3, 3 }; -+ -+static const int mt7988_pcie_p1_phy_i2c_pins[] = { 7, 8 }; -+static const int mt7988_pcie_p1_phy_i2c_funcs[] = { 4, 4 }; -+ -+static const int mt7988_pcie_p3_phy_i2c_pins[] = { 9, 10 }; -+static const int mt7988_pcie_p3_phy_i2c_funcs[] = { 4, 4 }; -+ -+static const int mt7988_pcie_p2_phy_i2c_pins[] = { 7, 8 }; -+static const int mt7988_pcie_p2_phy_i2c_funcs[] = { 5, 5 }; -+ -+static const int mt7988_ckm_phy_i2c_pins[] = { 9, 10 }; -+static const int mt7988_ckm_phy_i2c_funcs[] = { 5, 5 }; -+ -+static const int mt7988_pcie_wake_n0_1_pins[] = { 13 }; -+static const int mt7988_pcie_wake_n0_1_funcs[] = { 2 }; -+ -+static const int mt7988_pcie_wake_n3_1_pins[] = { 14 }; -+static const int mt7988_pcie_wake_n3_1_funcs[] = { 2 }; -+ -+static const int mt7988_pcie_2l_0_pereset_pins[] = { 19 }; -+static const int mt7988_pcie_2l_0_pereset_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_1l_1_pereset_pins[] = { 20 }; -+static const int mt7988_pcie_1l_1_pereset_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n2_1_pins[] = { 63 }; -+static const int mt7988_pcie_clk_req_n2_1_funcs[] = { 2 }; -+ -+static const int mt7988_pcie_2l_1_pereset_pins[] = { 73 }; -+static const int mt7988_pcie_2l_1_pereset_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_1l_0_pereset_pins[] = { 74 }; -+static const int mt7988_pcie_1l_0_pereset_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_wake_n1_0_pins[] = { 75 }; -+static const int mt7988_pcie_wake_n1_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n1_pins[] = { 76 }; -+static const int mt7988_pcie_clk_req_n1_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_wake_n2_0_pins[] = { 77 }; -+static const int mt7988_pcie_wake_n2_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_clk_req_n2_0_pins[] = { 78 }; -+static const int mt7988_pcie_clk_req_n2_0_funcs[] = { 1 }; -+ -+static const int mt7988_pcie_wake_n2_1_pins[] = { 79 }; -+static const int mt7988_pcie_wake_n2_1_funcs[] = { 2 }; -+ -+/* pmic */ -+static const int mt7988_pmic_pins[] = { 11 }; -+static const int mt7988_pmic_funcs[] = { 1 }; -+ -+/* watchdog */ -+static const int mt7988_watchdog_pins[] = { 12 }; -+static const int mt7988_watchdog_funcs[] = { 1 }; -+ -+/* spi */ -+static const int mt7988_spi0_wp_hold_pins[] = { 22, 23 }; -+static const int mt7988_spi0_wp_hold_funcs[] = { 1, 1 }; -+ -+static const int mt7988_spi0_pins[] = { 24, 25, 26, 27 }; -+static const int mt7988_spi0_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_spi1_pins[] = { 28, 29, 30, 31 }; -+static const int mt7988_spi1_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_spi2_pins[] = { 32, 33, 34, 35 }; -+static const int mt7988_spi2_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_spi2_wp_hold_pins[] = { 36, 37 }; -+static const int mt7988_spi2_wp_hold_funcs[] = { 1, 1 }; -+ -+/* flash */ -+static const int mt7988_snfi_pins[] = { 22, 23, 24, 25, 26, 27 }; -+static const int mt7988_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 }; -+ -+static const int mt7988_emmc_45_pins[] = { -+ 21, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 }; -+static const int mt7988_emmc_45_funcs[] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; -+ -+static const int mt7988_emmc_51_pins[] = { -+ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 }; -+static const int mt7988_emmc_51_funcs[] = { -+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -+ -+/* uart */ -+static const int mt7988_uart2_pins[] = { 0, 1, 2, 3 }; -+static const int mt7988_uart2_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_tops_uart0_0_pins[] = { 22, 23 }; -+static const int mt7988_tops_uart0_0_funcs[] = { 3, 3 }; -+ -+static const int mt7988_uart2_0_pins[] = { 28, 29, 30, 31 }; -+static const int mt7988_uart2_0_funcs[] = { 2, 2, 2, 2 }; -+ -+static const int mt7988_uart1_0_pins[] = { 32, 33, 34, 35 }; -+static const int mt7988_uart1_0_funcs[] = { 2, 2, 2, 2 }; -+ -+static const int mt7988_uart2_1_pins[] = { 32, 33, 34, 35 }; -+static const int mt7988_uart2_1_funcs[] = { 3, 3, 3, 3 }; -+ -+static const int mt7988_net_wo0_uart_txd_0_pins[] = { 28 }; -+static const int mt7988_net_wo0_uart_txd_0_funcs[] = { 3 }; -+ -+static const int mt7988_net_wo1_uart_txd_0_pins[] = { 29 }; -+static const int mt7988_net_wo1_uart_txd_0_funcs[] = { 3 }; -+ -+static const int mt7988_net_wo2_uart_txd_0_pins[] = { 30 }; -+static const int mt7988_net_wo2_uart_txd_0_funcs[] = { 3 }; -+ -+static const int mt7988_tops_uart1_0_pins[] = { 28, 29 }; -+static const int mt7988_tops_uart1_0_funcs[] = { 4, 4 }; -+ -+static const int mt7988_tops_uart0_1_pins[] = { 30, 31 }; -+static const int mt7988_tops_uart0_1_funcs[] = { 4, 4 }; -+ -+static const int mt7988_tops_uart1_1_pins[] = { 36, 37 }; -+static const int mt7988_tops_uart1_1_funcs[] = { 3, 3 }; -+ -+static const int mt7988_uart0_pins[] = { 55, 56 }; -+static const int mt7988_uart0_funcs[] = { 1, 1 }; -+ -+static const int mt7988_tops_uart0_2_pins[] = { 55, 56 }; -+static const int mt7988_tops_uart0_2_funcs[] = { 2, 2 }; -+ -+static const int mt7988_uart2_2_pins[] = { 50, 51, 52, 53 }; -+static const int mt7988_uart2_2_funcs[] = { 2, 2, 2, 2 }; -+ -+static const int mt7988_uart1_1_pins[] = { 58, 59, 60, 61 }; -+static const int mt7988_uart1_1_funcs[] = { 2, 2, 2, 2 }; -+ -+static const int mt7988_uart2_3_pins[] = { 58, 59, 60, 61 }; -+static const int mt7988_uart2_3_funcs[] = { 3, 3, 3, 3 }; -+ -+static const int mt7988_uart1_2_pins[] = { 80, 81, 82, 83 }; -+static const int mt7988_uart1_2_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_tops_uart1_2_pins[] = { 80, 81 }; -+static const int mt7988_tops_uart1_2_funcs[] = { 4, 4, }; -+ -+static const int mt7988_net_wo0_uart_txd_1_pins[] = { 80 }; -+static const int mt7988_net_wo0_uart_txd_1_funcs[] = { 3 }; -+ -+static const int mt7988_net_wo1_uart_txd_1_pins[] = { 81 }; -+static const int mt7988_net_wo1_uart_txd_1_funcs[] = { 3 }; -+ -+static const int mt7988_net_wo2_uart_txd_1_pins[] = { 82 }; -+static const int mt7988_net_wo2_uart_txd_1_funcs[] = { 3 }; -+ -+/* udi */ -+static const int mt7988_udi_pins[] = { 32, 33, 34, 35, 36 }; -+static const int mt7988_udi_funcs[] = { 4, 4, 4, 4, 4 }; -+ -+/* pcm */ -+static const int mt7988_pcm_pins[] = { 50, 51, 52, 53, 54 }; -+static const int mt7988_pcm_funcs[] = { 1, 1, 1, 1, 1 }; -+ -+/* led */ -+static const int mt7988_gbe_led1_pins[] = { 58, 59, 60, 61 }; -+static const int mt7988_gbe_led1_funcs[] = { 6, 6, 6, 6 }; -+ -+static const int mt7988_2p5gbe_led1_pins[] = { 62 }; -+static const int mt7988_2p5gbe_led1_funcs[] = { 6 }; -+ -+static const int mt7988_gbe_led0_pins[] = { 64, 65, 66, 67 }; -+static const int mt7988_gbe_led0_funcs[] = { 1, 1, 1, 1 }; -+ -+static const int mt7988_2p5gbe_led0_pins[] = { 68 }; -+static const int mt7988_2p5gbe_led0_funcs[] = { 1 }; -+ -+/* usb */ -+static const int mt7988_drv_vbus_p1_pins[] = { 63 }; -+static const int mt7988_drv_vbus_p1_funcs[] = { 1 }; -+ -+static const int mt7988_drv_vbus_pins[] = { 79 }; -+static const int mt7988_drv_vbus_funcs[] = { 1 }; -+ -+static const struct mtk_group_desc mt7988_groups[] = { -+ PINCTRL_PIN_GROUP("uart2", mt7988_uart2), -+ PINCTRL_PIN_GROUP("tops_jtag0_0", mt7988_tops_jtag0_0), -+ PINCTRL_PIN_GROUP("int_usxgmii", mt7988_int_usxgmii), -+ PINCTRL_PIN_GROUP("dfd", mt7988_dfd), -+ PINCTRL_PIN_GROUP("xfi_phy0_i2c0", mt7988_xfi_phy0_i2c0), -+ PINCTRL_PIN_GROUP("xfi_phy1_i2c0", mt7988_xfi_phy1_i2c0), -+ PINCTRL_PIN_GROUP("xfi_phy_pll_i2c0", mt7988_xfi_phy_pll_i2c0), -+ PINCTRL_PIN_GROUP("xfi_phy_pll_i2c1", mt7988_xfi_phy_pll_i2c1), -+ PINCTRL_PIN_GROUP("i2c0_0", mt7988_i2c0_0), -+ PINCTRL_PIN_GROUP("i2c1_sfp", mt7988_i2c1_sfp), -+ PINCTRL_PIN_GROUP("xfi_pextp_phy0_i2c", mt7988_xfi_pextp_phy0_i2c), -+ PINCTRL_PIN_GROUP("xfi_pextp_phy1_i2c", mt7988_xfi_pextp_phy1_i2c), -+ PINCTRL_PIN_GROUP("mdc_mdio0", mt7988_mdc_mdio0), -+ PINCTRL_PIN_GROUP("pcie_wake_n0_0", mt7988_pcie_wake_n0_0), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n0_0", mt7988_pcie_clk_req_n0_0), -+ PINCTRL_PIN_GROUP("pcie_wake_n3_0", mt7988_pcie_wake_n3_0), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n3", mt7988_pcie_clk_req_n3), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n0_1", mt7988_pcie_clk_req_n0_1), -+ PINCTRL_PIN_GROUP("pcie_p0_phy_i2c", mt7988_pcie_p0_phy_i2c), -+ PINCTRL_PIN_GROUP("pcie_p1_phy_i2c", mt7988_pcie_p1_phy_i2c), -+ PINCTRL_PIN_GROUP("pcie_p2_phy_i2c", mt7988_pcie_p2_phy_i2c), -+ PINCTRL_PIN_GROUP("pcie_p3_phy_i2c", mt7988_pcie_p3_phy_i2c), -+ PINCTRL_PIN_GROUP("ckm_phy_i2c", mt7988_ckm_phy_i2c), -+ PINCTRL_PIN_GROUP("pcie_pmic", mt7988_pmic), -+ PINCTRL_PIN_GROUP("watchdog", mt7988_watchdog), -+ PINCTRL_PIN_GROUP("pcie_wake_n0_1", mt7988_pcie_wake_n0_1), -+ PINCTRL_PIN_GROUP("pcie_wake_n3_1", mt7988_pcie_wake_n3_1), -+ PINCTRL_PIN_GROUP("i2c0_1", mt7988_i2c0_1), -+ PINCTRL_PIN_GROUP("u30_phy_i2c0", mt7988_u30_phy_i2c0), -+ PINCTRL_PIN_GROUP("u32_phy_i2c0", mt7988_u32_phy_i2c0), -+ PINCTRL_PIN_GROUP("xfi_phy0_i2c1", mt7988_xfi_phy0_i2c1), -+ PINCTRL_PIN_GROUP("xfi_phy1_i2c1", mt7988_xfi_phy1_i2c1), -+ PINCTRL_PIN_GROUP("xfi_phy_pll_i2c2", mt7988_xfi_phy_pll_i2c2), -+ PINCTRL_PIN_GROUP("i2c1_0", mt7988_i2c1_0), -+ PINCTRL_PIN_GROUP("u30_phy_i2c1", mt7988_u30_phy_i2c1), -+ PINCTRL_PIN_GROUP("u32_phy_i2c1", mt7988_u32_phy_i2c1), -+ PINCTRL_PIN_GROUP("xfi_phy_pll_i2c3", mt7988_xfi_phy_pll_i2c3), -+ PINCTRL_PIN_GROUP("sgmii0_i2c", mt7988_sgmii0_i2c), -+ PINCTRL_PIN_GROUP("sgmii1_i2c", mt7988_sgmii1_i2c), -+ PINCTRL_PIN_GROUP("pcie_2l_0_pereset", mt7988_pcie_2l_0_pereset), -+ PINCTRL_PIN_GROUP("pcie_1l_1_pereset", mt7988_pcie_1l_1_pereset), -+ PINCTRL_PIN_GROUP("pwm1", mt7988_pwm1), -+ PINCTRL_PIN_GROUP("spi0_wp_hold", mt7988_spi0_wp_hold), -+ PINCTRL_PIN_GROUP("spi0", mt7988_spi0), -+ PINCTRL_PIN_GROUP("spi1", mt7988_spi1), -+ PINCTRL_PIN_GROUP("spi2", mt7988_spi2), -+ PINCTRL_PIN_GROUP("spi2_wp_hold", mt7988_spi2_wp_hold), -+ PINCTRL_PIN_GROUP("snfi", mt7988_snfi), -+ PINCTRL_PIN_GROUP("tops_uart0_0", mt7988_tops_uart0_0), -+ PINCTRL_PIN_GROUP("uart2_0", mt7988_uart2_0), -+ PINCTRL_PIN_GROUP("uart1_0", mt7988_uart1_0), -+ PINCTRL_PIN_GROUP("uart2_1", mt7988_uart2_1), -+ PINCTRL_PIN_GROUP("net_wo0_uart_txd_0", mt7988_net_wo0_uart_txd_0), -+ PINCTRL_PIN_GROUP("net_wo1_uart_txd_0", mt7988_net_wo1_uart_txd_0), -+ PINCTRL_PIN_GROUP("net_wo2_uart_txd_0", mt7988_net_wo2_uart_txd_0), -+ PINCTRL_PIN_GROUP("tops_uart0_0", mt7988_tops_uart1_0), -+ PINCTRL_PIN_GROUP("tops_uart0_1", mt7988_tops_uart0_1), -+ PINCTRL_PIN_GROUP("tops_uart1_1", mt7988_tops_uart1_1), -+ PINCTRL_PIN_GROUP("udi", mt7988_udi), -+ PINCTRL_PIN_GROUP("emmc_45", mt7988_emmc_45), -+ PINCTRL_PIN_GROUP("emmc_51", mt7988_emmc_51), -+ PINCTRL_PIN_GROUP("2p5g_ext_mdio", mt7988_2p5g_ext_mdio), -+ PINCTRL_PIN_GROUP("gbe_ext_mdio", mt7988_gbe_ext_mdio), -+ PINCTRL_PIN_GROUP("pcm", mt7988_pcm), -+ PINCTRL_PIN_GROUP("uart0", mt7988_uart0), -+ PINCTRL_PIN_GROUP("tops_uart0_2", mt7988_tops_uart0_2), -+ PINCTRL_PIN_GROUP("uart2_2", mt7988_uart2_2), -+ PINCTRL_PIN_GROUP("wo0_jtag", mt7988_wo0_jtag), -+ PINCTRL_PIN_GROUP("wo1_jtag", mt7988_wo1_jtag), -+ PINCTRL_PIN_GROUP("wo2_jtag", mt7988_wo2_jtag), -+ PINCTRL_PIN_GROUP("pwm0", mt7988_pwm0), -+ PINCTRL_PIN_GROUP("jtag", mt7988_jtag), -+ PINCTRL_PIN_GROUP("tops_jtag0_1", mt7988_tops_jtag0_1), -+ PINCTRL_PIN_GROUP("uart2_3", mt7988_uart2_3), -+ PINCTRL_PIN_GROUP("uart1_1", mt7988_uart1_1), -+ PINCTRL_PIN_GROUP("gbe_led1", mt7988_gbe_led1), -+ PINCTRL_PIN_GROUP("2p5gbe_led1", mt7988_2p5gbe_led1), -+ PINCTRL_PIN_GROUP("gbe_led0", mt7988_gbe_led0), -+ PINCTRL_PIN_GROUP("2p5gbe_led0", mt7988_2p5gbe_led0), -+ PINCTRL_PIN_GROUP("drv_vbus_p1", mt7988_drv_vbus_p1), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n2_1", mt7988_pcie_clk_req_n2_1), -+ PINCTRL_PIN_GROUP("mdc_mdio1", mt7988_mdc_mdio1), -+ PINCTRL_PIN_GROUP("i2c1_2", mt7988_i2c1_2), -+ PINCTRL_PIN_GROUP("pwm6", mt7988_pwm6), -+ PINCTRL_PIN_GROUP("pwm7", mt7988_pwm7), -+ PINCTRL_PIN_GROUP("i2c2_0", mt7988_i2c2_0), -+ PINCTRL_PIN_GROUP("i2c2_1", mt7988_i2c2_1), -+ PINCTRL_PIN_GROUP("pcie_2l_1_pereset", mt7988_pcie_2l_1_pereset), -+ PINCTRL_PIN_GROUP("pcie_1l_0_pereset", mt7988_pcie_1l_0_pereset), -+ PINCTRL_PIN_GROUP("pcie_wake_n1_0", mt7988_pcie_wake_n1_0), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n1", mt7988_pcie_clk_req_n1), -+ PINCTRL_PIN_GROUP("pcie_wake_n2_0", mt7988_pcie_wake_n2_0), -+ PINCTRL_PIN_GROUP("pcie_clk_req_n2_0", mt7988_pcie_clk_req_n2_0), -+ PINCTRL_PIN_GROUP("drv_vbus", mt7988_drv_vbus), -+ PINCTRL_PIN_GROUP("pcie_wake_n2_1", mt7988_pcie_wake_n2_1), -+ PINCTRL_PIN_GROUP("uart1_2", mt7988_uart1_2), -+ PINCTRL_PIN_GROUP("pwm2", mt7988_pwm2), -+ PINCTRL_PIN_GROUP("pwm3", mt7988_pwm3), -+ PINCTRL_PIN_GROUP("pwm4", mt7988_pwm4), -+ PINCTRL_PIN_GROUP("pwm5", mt7988_pwm5), -+ PINCTRL_PIN_GROUP("net_wo0_uart_txd_0", mt7988_net_wo0_uart_txd_0), -+ PINCTRL_PIN_GROUP("net_wo1_uart_txd_0", mt7988_net_wo1_uart_txd_0), -+ PINCTRL_PIN_GROUP("net_wo2_uart_txd_0", mt7988_net_wo2_uart_txd_0), -+ PINCTRL_PIN_GROUP("tops_uart1_2", mt7988_tops_uart1_2), -+ PINCTRL_PIN_GROUP("net_wo0_uart_txd_1", mt7988_net_wo0_uart_txd_1), -+ PINCTRL_PIN_GROUP("net_wo1_uart_txd_1", mt7988_net_wo1_uart_txd_1), -+ PINCTRL_PIN_GROUP("net_wo2_uart_txd_1", mt7988_net_wo2_uart_txd_1), -+}; -+ -+static const struct mtk_io_type_desc mt7988_io_type_desc[] = { -+ [IO_TYPE_GRP0] = { -+ .name = "18OD33", -+ .bias_set = mtk_pinconf_bias_set_pupd_r1_r0, -+ .drive_set = mtk_pinconf_drive_set_v1, -+ .input_enable = mtk_pinconf_input_enable_v1, -+ }, -+ [IO_TYPE_GRP1] = { -+ .name = "18A01", -+ .bias_set = mtk_pinconf_bias_set_pu_pd, -+ .drive_set = mtk_pinconf_drive_set_v1, -+ .input_enable = mtk_pinconf_input_enable_v1, -+ }, -+ [IO_TYPE_GRP2] = { -+ .name = "I2C", -+ .input_enable = mtk_pinconf_input_enable_v1, -+ }, -+}; -+ -+/* Joint those groups owning the same capability in user point of view which -+ * allows that people tend to use through the device tree. -+ */ -+static const char *const mt7988_jtag_groups[] = { "tops_jtag0_0", "wo0_jtag", -+ "wo1_jtag", "wo2_jtag", "jtag", "tops_jtag0_1", }; -+static const char *const mt7988_int_usxgmii_groups[] = { "int_usxgmii", }; -+static const char *const mt7988_pwm_groups[] = { "pwm0", "pwm1", "pwm2", "pwm3", -+ "pwm4", "pwm5", "pwm6", "pwm7" }; -+static const char *const mt7988_dfd_groups[] = { "dfd", }; -+static const char *const mt7988_i2c_groups[] = { "xfi_phy0_i2c0", -+ "xfi_phy1_i2c0", "xfi_phy_pll_i2c0", "xfi_phy_pll_i2c1", "i2c0_0", -+ "i2c1_sfp", "xfi_pextp_phy0_i2c", "xfi_pextp_phy1_i2c", "i2c0_1", -+ "u30_phy_i2c0", "u32_phy_i2c0", "xfi_phy0_i2c1", "xfi_phy1_i2c1", -+ "xfi_phy_pll_i2c2", "i2c1_0", "u30_phy_i2c1", "u32_phy_i2c1", -+ "xfi_phy_pll_i2c3", "sgmii0_i2c", "sgmii1_i2c", "i2c1_2", "i2c2_0", -+ "i2c2_1", }; -+static const char *const mt7988_ethernet_groups[] = { "mdc_mdio0", -+ "2p5g_ext_mdio", "gbe_ext_mdio", "mdc_mdio1", }; -+static const char *const mt7988_pcie_groups[] = { "pcie_wake_n0_0", -+ "pcie_clk_req_n0_0", "pcie_wake_n3_0", "pcie_clk_req_n3", -+ "pcie_p0_phy_i2c", "pcie_p1_phy_i2c", "pcie_p3_phy_i2", -+ "pcie_p2_phy_i2c", "ckm_phy_i2c", "pcie_wake_n0_1", "pcie_wake_n3_1", -+ "pcie_2l_0_pereset", "pcie_1l_1_pereset", "pcie_clk_req_n2_1", -+ "pcie_2l_1_perese", "pcie_1l_0_pereset", "pcie_wake_n1_0", -+ "cie_clk_req_n1", "pcie_wake_n2_0", "pcie_wake_n2_1", }; -+static const char *const mt7988_pmic_groups[] = { "pmic", }; -+static const char *const mt7988_wdt_groups[] = { "watchdog", }; -+static const char *const mt7988_spi_groups[] = { "spi0", "spi0_wp_hold", -+ "spi1", "spi2", "spi2_wp_hold", }; -+static const char *const mt7988_flash_groups[] = { "emmc_45", "snfi", -+ "emmc_51" }; -+static const char *const mt7988_uart_groups[] = { "uart2", "tops_uart0_0", -+ "uart2_0", "uart1_0", "uart2_1", -+ "net_wo0_uart_txd_0", "net_wo1_uart_txd_0", "net_wo2_uart_txd_0", -+ "tops_uart1_0", "ops_uart0_1", "ops_uart1_1", -+ "uart0", "tops_uart0_2", "uart1_1", -+ "uart2_3", "uart1_2", "tops_uart1_2", -+ "net_wo0_uart_txd_1", "net_wo1_uart_txd_1", "net_wo2_uart_txd_1", }; -+static const char *const mt7988_udi_groups[] = { "udi", }; -+static const char *const mt7988_pcm_groups[] = { "pcm", }; -+static const char *const mt7988_led_groups[] = { "gbe_led1", "2p5gbe_led1", -+ "gbe_led0", "2p5gbe_led0", "wf5g_led0", "wf5g_led1", }; -+static const char *const mt7988_usb_groups[] = { "drv_vbus", "drv_vbus_p1", }; -+ -+static const struct mtk_function_desc mt7988_functions[] = { -+ {"jtag", mt7988_jtag_groups, ARRAY_SIZE(mt7988_jtag_groups)}, -+ {"int_usxgmii", mt7988_int_usxgmii_groups, -+ ARRAY_SIZE(mt7988_int_usxgmii_groups)}, -+ {"pwm", mt7988_pwm_groups, ARRAY_SIZE(mt7988_pwm_groups)}, -+ {"dfd", mt7988_dfd_groups, ARRAY_SIZE(mt7988_dfd_groups)}, -+ {"i2c", mt7988_i2c_groups, ARRAY_SIZE(mt7988_i2c_groups)}, -+ {"eth", mt7988_ethernet_groups, ARRAY_SIZE(mt7988_ethernet_groups)}, -+ {"pcie", mt7988_pcie_groups, ARRAY_SIZE(mt7988_pcie_groups)}, -+ {"pmic", mt7988_pmic_groups, ARRAY_SIZE(mt7988_pmic_groups)}, -+ {"watchdog", mt7988_wdt_groups, ARRAY_SIZE(mt7988_wdt_groups)}, -+ {"spi", mt7988_spi_groups, ARRAY_SIZE(mt7988_spi_groups)}, -+ {"flash", mt7988_flash_groups, ARRAY_SIZE(mt7988_flash_groups)}, -+ {"uart", mt7988_uart_groups, ARRAY_SIZE(mt7988_uart_groups)}, -+ {"udi", mt7988_udi_groups, ARRAY_SIZE(mt7988_udi_groups)}, -+ {"pcm", mt7988_pcm_groups, ARRAY_SIZE(mt7988_pcm_groups)}, -+ {"usb", mt7988_usb_groups, ARRAY_SIZE(mt7988_usb_groups)}, -+ {"led", mt7988_led_groups, ARRAY_SIZE(mt7988_led_groups)}, -+}; -+ -+static const char *const mt7988_pinctrl_register_base_names[] = { -+ "gpio_base", "iocfg_tr_base", "iocfg_br_base", "iocfg_rb_base", -+ "iocfg_lb_base", "iocfg_tl_base", -+}; -+ -+static const struct mtk_pinctrl_soc mt7988_data = { -+ .name = "mt7988_pinctrl", -+ .reg_cal = mt7988_reg_cals, -+ .pins = mt7988_pins, -+ .npins = ARRAY_SIZE(mt7988_pins), -+ .grps = mt7988_groups, -+ .ngrps = ARRAY_SIZE(mt7988_groups), -+ .funcs = mt7988_functions, -+ .nfuncs = ARRAY_SIZE(mt7988_functions), -+ .io_type = mt7988_io_type_desc, -+ .ntype = ARRAY_SIZE(mt7988_io_type_desc), -+ .gpio_mode = 0, -+ .base_names = mt7988_pinctrl_register_base_names, -+ .nbase_names = ARRAY_SIZE(mt7988_pinctrl_register_base_names), -+ .base_calc = 1, -+}; -+ -+static int mtk_pinctrl_mt7988_probe(struct udevice *dev) -+{ -+ return mtk_pinctrl_common_probe(dev, &mt7988_data); -+} -+ -+static const struct udevice_id mt7988_pctrl_match[] = { -+ {.compatible = "mediatek,mt7988-pinctrl"}, -+ { /* sentinel */ } -+}; -+ -+U_BOOT_DRIVER(mt7988_pinctrl) = { -+ .name = "mt7988_pinctrl", -+ .id = UCLASS_PINCTRL, -+ .of_match = mt7988_pctrl_match, -+ .ops = &mtk_pinctrl_ops, -+ .probe = mtk_pinctrl_mt7988_probe, -+ .priv_auto = sizeof(struct mtk_pinctrl_priv), -+}; diff --git a/package/boot/uboot-mediatek/patches/101-16-net-mediatek-connect-switch-to-PSE-only-when-startin.patch b/package/boot/uboot-mediatek/patches/101-16-net-mediatek-connect-switch-to-PSE-only-when-startin.patch deleted file mode 100644 index e3e6212742b6f5..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-16-net-mediatek-connect-switch-to-PSE-only-when-startin.patch +++ /dev/null @@ -1,138 +0,0 @@ -From a0405999ebecf21ed9f76f1dc9420682cd3feba0 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:54 +0800 -Subject: [PATCH 16/29] net: mediatek: connect switch to PSE only when starting - eth is requested - -So far the switch is initialized in probe stage and is connected to PSE -unconditionally. This will cause all packets being flooded to PSE and may -cause PSE hang before entering linux. - -This patch changes the connection between switch and PSE: -- Still initialize switch in probe stage, but disconnect it with PSE -- Connect switch with PSE on eth start -- Disconnect on eth stop - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 44 ++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 41 insertions(+), 3 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -123,8 +123,10 @@ struct mtk_eth_priv { - - enum mtk_switch sw; - int (*switch_init)(struct mtk_eth_priv *priv); -+ void (*switch_mac_control)(struct mtk_eth_priv *priv, bool enable); - u32 mt753x_smi_addr; - u32 mt753x_phy_base; -+ u32 mt753x_pmcr; - - struct gpio_desc rst_gpio; - int mcm; -@@ -613,6 +615,16 @@ static int mt7530_pad_clk_setup(struct m - return 0; - } - -+static void mt7530_mac_control(struct mtk_eth_priv *priv, bool enable) -+{ -+ u32 pmcr = FORCE_MODE; -+ -+ if (enable) -+ pmcr = priv->mt753x_pmcr; -+ -+ mt753x_reg_write(priv, PMCR_REG(6), pmcr); -+} -+ - static int mt7530_setup(struct mtk_eth_priv *priv) - { - u16 phy_addr, phy_val; -@@ -663,11 +675,14 @@ static int mt7530_setup(struct mtk_eth_p - FORCE_DPX | FORCE_LINK; - - /* MT7530 Port6: Forced 1000M/FD, FC disabled */ -- mt753x_reg_write(priv, PMCR_REG(6), val); -+ priv->mt753x_pmcr = val; - - /* MT7530 Port5: Forced link down */ - mt753x_reg_write(priv, PMCR_REG(5), FORCE_MODE); - -+ /* Keep MAC link down before starting eth */ -+ mt753x_reg_write(priv, PMCR_REG(6), FORCE_MODE); -+ - /* MT7530 Port6: Set to RGMII */ - mt753x_reg_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_M, P6_INTF_MODE_RGMII); - -@@ -823,6 +838,17 @@ static void mt7531_phy_setting(struct mt - } - } - -+static void mt7531_mac_control(struct mtk_eth_priv *priv, bool enable) -+{ -+ u32 pmcr = FORCE_MODE_LNK; -+ -+ if (enable) -+ pmcr = priv->mt753x_pmcr; -+ -+ mt753x_reg_write(priv, PMCR_REG(5), pmcr); -+ mt753x_reg_write(priv, PMCR_REG(6), pmcr); -+} -+ - static int mt7531_setup(struct mtk_eth_priv *priv) - { - u16 phy_addr, phy_val; -@@ -882,8 +908,11 @@ static int mt7531_setup(struct mtk_eth_p - (SPEED_1000M << FORCE_SPD_S) | FORCE_DPX | - FORCE_LINK; - -- mt753x_reg_write(priv, PMCR_REG(5), pmcr); -- mt753x_reg_write(priv, PMCR_REG(6), pmcr); -+ priv->mt753x_pmcr = pmcr; -+ -+ /* Keep MAC link down before starting eth */ -+ mt753x_reg_write(priv, PMCR_REG(5), FORCE_MODE_LNK); -+ mt753x_reg_write(priv, PMCR_REG(6), FORCE_MODE_LNK); - - /* Turn on PHYs */ - for (i = 0; i < MT753X_NUM_PHYS; i++) { -@@ -1227,6 +1256,9 @@ static int mtk_eth_start(struct udevice - - mtk_eth_fifo_init(priv); - -+ if (priv->switch_mac_control) -+ priv->switch_mac_control(priv, true); -+ - /* Start PHY */ - if (priv->sw == SW_NONE) { - ret = mtk_phy_start(priv); -@@ -1245,6 +1277,9 @@ static void mtk_eth_stop(struct udevice - { - struct mtk_eth_priv *priv = dev_get_priv(dev); - -+ if (priv->switch_mac_control) -+ priv->switch_mac_control(priv, false); -+ - mtk_pdma_rmw(priv, PDMA_GLO_CFG_REG, - TX_WB_DDONE | RX_DMA_EN | TX_DMA_EN, 0); - udelay(500); -@@ -1484,16 +1519,19 @@ static int mtk_eth_of_to_plat(struct ude - /* check for switch first, otherwise phy will be used */ - priv->sw = SW_NONE; - priv->switch_init = NULL; -+ priv->switch_mac_control = NULL; - str = dev_read_string(dev, "mediatek,switch"); - - if (str) { - if (!strcmp(str, "mt7530")) { - priv->sw = SW_MT7530; - priv->switch_init = mt7530_setup; -+ priv->switch_mac_control = mt7530_mac_control; - priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; - } else if (!strcmp(str, "mt7531")) { - priv->sw = SW_MT7531; - priv->switch_init = mt7531_setup; -+ priv->switch_mac_control = mt7531_mac_control; - priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; - } else { - printf("error: unsupported switch\n"); diff --git a/package/boot/uboot-mediatek/patches/101-17-net-mediatek-optimize-the-switch-reset-delay-wait-ti.patch b/package/boot/uboot-mediatek/patches/101-17-net-mediatek-optimize-the-switch-reset-delay-wait-ti.patch deleted file mode 100644 index c8823ac545ce4a..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-17-net-mediatek-optimize-the-switch-reset-delay-wait-ti.patch +++ /dev/null @@ -1,56 +0,0 @@ -From d9a52701f6677889cc3332ab7a888f35cd69cc76 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:16:59 +0800 -Subject: [PATCH 17/29] net: mediatek: optimize the switch reset delay wait - time - -Not all switches requires 1 second delay after deasserting reset. -MT7531 requires only maximum 200ms. - -This patch defines dedicated reset wait time for each switch chip, and will -significantly improve the boot time for boards using MT7531. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -127,6 +127,7 @@ struct mtk_eth_priv { - u32 mt753x_smi_addr; - u32 mt753x_phy_base; - u32 mt753x_pmcr; -+ u32 mt753x_reset_wait_time; - - struct gpio_desc rst_gpio; - int mcm; -@@ -943,12 +944,12 @@ int mt753x_switch_init(struct mtk_eth_pr - reset_assert(&priv->rst_mcm); - udelay(1000); - reset_deassert(&priv->rst_mcm); -- mdelay(1000); -+ mdelay(priv->mt753x_reset_wait_time); - } else if (dm_gpio_is_valid(&priv->rst_gpio)) { - dm_gpio_set_value(&priv->rst_gpio, 0); - udelay(1000); - dm_gpio_set_value(&priv->rst_gpio, 1); -- mdelay(1000); -+ mdelay(priv->mt753x_reset_wait_time); - } - - ret = priv->switch_init(priv); -@@ -1528,11 +1529,13 @@ static int mtk_eth_of_to_plat(struct ude - priv->switch_init = mt7530_setup; - priv->switch_mac_control = mt7530_mac_control; - priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; -+ priv->mt753x_reset_wait_time = 1000; - } else if (!strcmp(str, "mt7531")) { - priv->sw = SW_MT7531; - priv->switch_init = mt7531_setup; - priv->switch_mac_control = mt7531_mac_control; - priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; -+ priv->mt753x_reset_wait_time = 200; - } else { - printf("error: unsupported switch\n"); - return -EINVAL; diff --git a/package/boot/uboot-mediatek/patches/101-18-net-mediatek-fix-direct-MDIO-clause-45-access-via-So.patch b/package/boot/uboot-mediatek/patches/101-18-net-mediatek-fix-direct-MDIO-clause-45-access-via-So.patch deleted file mode 100644 index 5214e842c82656..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-18-net-mediatek-fix-direct-MDIO-clause-45-access-via-So.patch +++ /dev/null @@ -1,34 +0,0 @@ -From c44f6ac1a31961b0d4faf982ee42167de5ac1672 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:03 +0800 -Subject: [PATCH 18/29] net: mediatek: fix direct MDIO clause 45 access via SoC - -The original direct MDIO clause 45 access via SoC is missing the -data output. This patch adds it back to ensure MDIO clause 45 can -work properly for external PHYs. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -198,7 +198,7 @@ static int mtk_mii_rw(struct mtk_eth_pri - (((u32)phy << MDIO_PHY_ADDR_S) & MDIO_PHY_ADDR_M) | - (((u32)reg << MDIO_REG_ADDR_S) & MDIO_REG_ADDR_M); - -- if (cmd == MDIO_CMD_WRITE) -+ if (cmd == MDIO_CMD_WRITE || cmd == MDIO_CMD_ADDR) - val |= data & MDIO_RW_DATA_M; - - mtk_gmac_write(priv, GMAC_PIAC_REG, val | PHY_ACS_ST); -@@ -210,7 +210,7 @@ static int mtk_mii_rw(struct mtk_eth_pri - return ret; - } - -- if (cmd == MDIO_CMD_READ) { -+ if (cmd == MDIO_CMD_READ || cmd == MDIO_CMD_READ_C45) { - val = mtk_gmac_read(priv, GMAC_PIAC_REG); - return val & MDIO_RW_DATA_M; - } diff --git a/package/boot/uboot-mediatek/patches/101-19-net-mediatek-add-missing-static-qualifier.patch b/package/boot/uboot-mediatek/patches/101-19-net-mediatek-add-missing-static-qualifier.patch deleted file mode 100644 index 9350ca04dc26c8..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-19-net-mediatek-add-missing-static-qualifier.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 9d35558bedfb82860c63cc11d3426afcbd82cb5c Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:07 +0800 -Subject: [PATCH 19/29] net: mediatek: add missing static qualifier - -mt7531_mmd_ind_read and mt753x_switch_init are defined without static. -Since they're not used outside this file, we should add them back. - -Signed-off-by: Weijie Gao - -fixup to add static qualifier ---- - drivers/net/mtk_eth.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -436,7 +436,8 @@ static int mt7531_mii_ind_write(struct m - MDIO_ST_C22); - } - --int mt7531_mmd_ind_read(struct mtk_eth_priv *priv, u8 addr, u8 devad, u16 reg) -+static int mt7531_mmd_ind_read(struct mtk_eth_priv *priv, u8 addr, u8 devad, -+ u16 reg) - { - u8 phy_addr; - int ret; -@@ -934,7 +935,7 @@ static int mt7531_setup(struct mtk_eth_p - return 0; - } - --int mt753x_switch_init(struct mtk_eth_priv *priv) -+static int mt753x_switch_init(struct mtk_eth_priv *priv) - { - int ret; - int i; diff --git a/package/boot/uboot-mediatek/patches/101-20-net-mediatek-add-support-for-SGMII-1Gbps-auto-negoti.patch b/package/boot/uboot-mediatek/patches/101-20-net-mediatek-add-support-for-SGMII-1Gbps-auto-negoti.patch deleted file mode 100644 index 45acbc36ac1bac..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-20-net-mediatek-add-support-for-SGMII-1Gbps-auto-negoti.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 8e59c3cc700a6efb8db574f3c8e18b6181b4a07d Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:13 +0800 -Subject: [PATCH 20/29] net: mediatek: add support for SGMII 1Gbps - auto-negotiation mode - -Existing SGMII support of mtk-eth is actually a MediaTek-specific -2.5Gbps high-speed SGMII (HSGMII) which does not support -auto-negotiation mode. - -This patch adds SGMII 1Gbps auto-negotiation mode and rename the -existing HSGMII to 2500basex. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 46 +++++++++++++++++++++++++++++++++++++------ - drivers/net/mtk_eth.h | 2 ++ - 2 files changed, 42 insertions(+), 6 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -893,7 +893,7 @@ static int mt7531_setup(struct mtk_eth_p - if (!port5_sgmii) - mt7531_port_rgmii_init(priv, 5); - break; -- case PHY_INTERFACE_MODE_SGMII: -+ case PHY_INTERFACE_MODE_2500BASEX: - mt7531_port_sgmii_init(priv, 6); - if (port5_sgmii) - mt7531_port_sgmii_init(priv, 5); -@@ -986,6 +986,7 @@ static void mtk_phy_link_adjust(struct m - (MAC_RX_PKT_LEN_1536 << MAC_RX_PKT_LEN_S) | - MAC_MODE | FORCE_MODE | - MAC_TX_EN | MAC_RX_EN | -+ DEL_RXFIFO_CLR | - BKOFF_EN | BACKPR_EN; - - switch (priv->phydev->speed) { -@@ -996,6 +997,7 @@ static void mtk_phy_link_adjust(struct m - mcr |= (SPEED_100M << FORCE_SPD_S); - break; - case SPEED_1000: -+ case SPEED_2500: - mcr |= (SPEED_1000M << FORCE_SPD_S); - break; - }; -@@ -1048,7 +1050,8 @@ static int mtk_phy_start(struct mtk_eth_ - return 0; - } - -- mtk_phy_link_adjust(priv); -+ if (!priv->force_mode) -+ mtk_phy_link_adjust(priv); - - debug("Speed: %d, %s duplex%s\n", phydev->speed, - (phydev->duplex) ? "full" : "half", -@@ -1076,7 +1079,31 @@ static int mtk_phy_probe(struct udevice - return 0; - } - --static void mtk_sgmii_init(struct mtk_eth_priv *priv) -+static void mtk_sgmii_an_init(struct mtk_eth_priv *priv) -+{ -+ /* Set SGMII GEN1 speed(1G) */ -+ clrsetbits_le32(priv->sgmii_base + priv->soc->ana_rgc3, -+ SGMSYS_SPEED_2500, 0); -+ -+ /* Enable SGMII AN */ -+ setbits_le32(priv->sgmii_base + SGMSYS_PCS_CONTROL_1, -+ SGMII_AN_ENABLE); -+ -+ /* SGMII AN mode setting */ -+ writel(SGMII_AN_MODE, priv->sgmii_base + SGMSYS_SGMII_MODE); -+ -+ /* SGMII PN SWAP setting */ -+ if (priv->pn_swap) { -+ setbits_le32(priv->sgmii_base + SGMSYS_QPHY_WRAP_CTRL, -+ SGMII_PN_SWAP_TX_RX); -+ } -+ -+ /* Release PHYA power down state */ -+ clrsetbits_le32(priv->sgmii_base + SGMSYS_QPHY_PWR_STATE_CTRL, -+ SGMII_PHYA_PWD, 0); -+} -+ -+static void mtk_sgmii_force_init(struct mtk_eth_priv *priv) - { - /* Set SGMII GEN2 speed(2.5G) */ - setbits_le32(priv->sgmii_base + priv->soc->ana_rgc3, -@@ -1111,10 +1138,14 @@ static void mtk_mac_init(struct mtk_eth_ - ge_mode = GE_MODE_RGMII; - break; - case PHY_INTERFACE_MODE_SGMII: -+ case PHY_INTERFACE_MODE_2500BASEX: - ge_mode = GE_MODE_RGMII; - mtk_ethsys_rmw(priv, ETHSYS_SYSCFG0_REG, SYSCFG0_SGMII_SEL_M, - SYSCFG0_SGMII_SEL(priv->gmac_id)); -- mtk_sgmii_init(priv); -+ if (priv->phy_interface == PHY_INTERFACE_MODE_SGMII) -+ mtk_sgmii_an_init(priv); -+ else -+ mtk_sgmii_force_init(priv); - break; - case PHY_INTERFACE_MODE_MII: - case PHY_INTERFACE_MODE_GMII: -@@ -1148,6 +1179,7 @@ static void mtk_mac_init(struct mtk_eth_ - mcr |= SPEED_100M << FORCE_SPD_S; - break; - case SPEED_1000: -+ case SPEED_2500: - mcr |= SPEED_1000M << FORCE_SPD_S; - break; - } -@@ -1490,13 +1522,15 @@ static int mtk_eth_of_to_plat(struct ude - priv->duplex = ofnode_read_bool(subnode, "full-duplex"); - - if (priv->speed != SPEED_10 && priv->speed != SPEED_100 && -- priv->speed != SPEED_1000) { -+ priv->speed != SPEED_1000 && priv->speed != SPEED_2500 && -+ priv->speed != SPEED_10000) { - printf("error: no valid speed set in fixed-link\n"); - return -EINVAL; - } - } - -- if (priv->phy_interface == PHY_INTERFACE_MODE_SGMII) { -+ if (priv->phy_interface == PHY_INTERFACE_MODE_SGMII || -+ priv->phy_interface == PHY_INTERFACE_MODE_2500BASEX) { - /* get corresponding sgmii phandle */ - ret = dev_read_phandle_with_args(dev, "mediatek,sgmiisys", - NULL, 0, 0, &args); ---- a/drivers/net/mtk_eth.h -+++ b/drivers/net/mtk_eth.h -@@ -69,6 +69,7 @@ enum mkt_eth_capabilities { - #define SGMII_AN_RESTART BIT(9) - - #define SGMSYS_SGMII_MODE 0x20 -+#define SGMII_AN_MODE 0x31120103 - #define SGMII_FORCE_MODE 0x31120019 - - #define SGMSYS_QPHY_PWR_STATE_CTRL 0xe8 -@@ -168,6 +169,7 @@ enum mkt_eth_capabilities { - #define FORCE_MODE BIT(15) - #define MAC_TX_EN BIT(14) - #define MAC_RX_EN BIT(13) -+#define DEL_RXFIFO_CLR BIT(12) - #define BKOFF_EN BIT(9) - #define BACKPR_EN BIT(8) - #define FORCE_RX_FC BIT(5) diff --git a/package/boot/uboot-mediatek/patches/101-21-arm-dts-medaitek-convert-gmac-link-mode-to-2500base-.patch b/package/boot/uboot-mediatek/patches/101-21-arm-dts-medaitek-convert-gmac-link-mode-to-2500base-.patch deleted file mode 100644 index 27612fd9e4e87c..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-21-arm-dts-medaitek-convert-gmac-link-mode-to-2500base-.patch +++ /dev/null @@ -1,214 +0,0 @@ -From 64ef7e977767e3b1305fb94a5169d8b7d3b19b6c Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:18 +0800 -Subject: [PATCH 21/29] arm: dts: mediatek: convert gmac link mode to - 2500base-x - -Now that individual 2.5Gbps SGMII support has been added to -mtk-eth, all boards that use 2.5Gbps link with mt7531 must be -converted to use "2500base-x" instead of "sgmii". - -Signed-off-by: Weijie Gao -[also convert BPi-R3] -Signed-off-by: Daniel Golle ---- - arch/arm/dts/mt7622-bananapi-bpi-r64.dts | 4 ++-- - arch/arm/dts/mt7622-rfb.dts | 4 ++-- - arch/arm/dts/mt7629-rfb.dts | 4 ++-- - arch/arm/dts/mt7981-emmc-rfb.dts | 4 ++-- - arch/arm/dts/mt7981-rfb.dts | 4 ++-- - arch/arm/dts/mt7981-sd-rfb.dts | 4 ++-- - arch/arm/dts/mt7986a-bpi-r3-sd.dts | 4 ++-- - arch/arm/dts/mt7986a-rfb.dts | 4 ++-- - arch/arm/dts/mt7986a-sd-rfb.dts | 4 ++-- - arch/arm/dts/mt7986b-rfb.dts | 4 ++-- - arch/arm/dts/mt7986b-sd-rfb.dts | 4 ++-- - 11 files changed, 22 insertions(+), 22 deletions(-) - ---- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts -+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts -@@ -224,12 +224,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 54 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7622-rfb.dts -+++ b/arch/arm/dts/mt7622-rfb.dts -@@ -240,12 +240,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 54 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7629-rfb.dts -+++ b/arch/arm/dts/mt7629-rfb.dts -@@ -25,12 +25,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 28 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7981-emmc-rfb.dts -+++ b/arch/arm/dts/mt7981-emmc-rfb.dts -@@ -46,12 +46,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7981-rfb.dts -+++ b/arch/arm/dts/mt7981-rfb.dts -@@ -37,12 +37,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7981-sd-rfb.dts -+++ b/arch/arm/dts/mt7981-sd-rfb.dts -@@ -46,12 +46,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7986a-bpi-r3-sd.dts -+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts -@@ -76,12 +76,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7986a-rfb.dts -+++ b/arch/arm/dts/mt7986a-rfb.dts -@@ -55,12 +55,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7986a-sd-rfb.dts -+++ b/arch/arm/dts/mt7986a-sd-rfb.dts -@@ -47,12 +47,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7986b-rfb.dts -+++ b/arch/arm/dts/mt7986b-rfb.dts -@@ -46,12 +46,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; ---- a/arch/arm/dts/mt7986b-sd-rfb.dts -+++ b/arch/arm/dts/mt7986b-sd-rfb.dts -@@ -47,12 +47,12 @@ - ð { - status = "okay"; - mediatek,gmac-id = <0>; -- phy-mode = "sgmii"; -+ phy-mode = "2500base-x"; - mediatek,switch = "mt7531"; - reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - - fixed-link { -- speed = <1000>; -+ speed = <2500>; - full-duplex; - }; - }; diff --git a/package/boot/uboot-mediatek/patches/101-22-net-mediatek-add-support-for-GMAC-USB3-PHY-mux-mode-.patch b/package/boot/uboot-mediatek/patches/101-22-net-mediatek-add-support-for-GMAC-USB3-PHY-mux-mode-.patch deleted file mode 100644 index c7e49ff304ddc2..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-22-net-mediatek-add-support-for-GMAC-USB3-PHY-mux-mode-.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 542d455466bdf32e1bb70230ebcdefd8ed09643b Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:22 +0800 -Subject: [PATCH 22/29] net: mediatek: add support for GMAC/USB3 PHY mux mode - for MT7981 - -MT7981 has its GMAC2 PHY shared with USB3. To enable GMAC2, mux -register must be set to connect the SGMII phy to GMAC2. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 33 ++++++++++++++++++++++++++++++++- - drivers/net/mtk_eth.h | 16 ++++++++++++++++ - 2 files changed, 48 insertions(+), 1 deletion(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -103,6 +103,8 @@ struct mtk_eth_priv { - - struct regmap *ethsys_regmap; - -+ struct regmap *infra_regmap; -+ - struct mii_dev *mdio_bus; - int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg); - int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val); -@@ -186,6 +188,17 @@ static void mtk_ethsys_rmw(struct mtk_et - regmap_write(priv->ethsys_regmap, reg, val); - } - -+static void mtk_infra_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, -+ u32 set) -+{ -+ uint val; -+ -+ regmap_read(priv->infra_regmap, reg, &val); -+ val &= ~clr; -+ val |= set; -+ regmap_write(priv->infra_regmap, reg, val); -+} -+ - /* Direct MDIO clause 22/45 access via SoC */ - static int mtk_mii_rw(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 data, - u32 cmd, u32 st) -@@ -1139,6 +1152,11 @@ static void mtk_mac_init(struct mtk_eth_ - break; - case PHY_INTERFACE_MODE_SGMII: - case PHY_INTERFACE_MODE_2500BASEX: -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_GMAC2_U3_QPHY)) { -+ mtk_infra_rmw(priv, USB_PHY_SWITCH_REG, QPHY_SEL_MASK, -+ SGMII_QPHY_SEL); -+ } -+ - ge_mode = GE_MODE_RGMII; - mtk_ethsys_rmw(priv, ETHSYS_SYSCFG0_REG, SYSCFG0_SGMII_SEL_M, - SYSCFG0_SGMII_SEL(priv->gmac_id)); -@@ -1497,6 +1515,19 @@ static int mtk_eth_of_to_plat(struct ude - if (IS_ERR(priv->ethsys_regmap)) - return PTR_ERR(priv->ethsys_regmap); - -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_INFRA)) { -+ /* get corresponding infracfg phandle */ -+ ret = dev_read_phandle_with_args(dev, "mediatek,infracfg", -+ NULL, 0, 0, &args); -+ -+ if (ret) -+ return ret; -+ -+ priv->infra_regmap = syscon_node_to_regmap(args.node); -+ if (IS_ERR(priv->infra_regmap)) -+ return PTR_ERR(priv->infra_regmap); -+ } -+ - /* Reset controllers */ - ret = reset_get_by_name(dev, "fe", &priv->rst_fe); - if (ret) { -@@ -1614,7 +1645,7 @@ static const struct mtk_soc_data mt7986_ - }; - - static const struct mtk_soc_data mt7981_data = { -- .caps = MT7986_CAPS, -+ .caps = MT7981_CAPS, - .ana_rgc3 = 0x128, - .pdma_base = PDMA_V2_BASE, - .txd_size = sizeof(struct mtk_tx_dma_v2), ---- a/drivers/net/mtk_eth.h -+++ b/drivers/net/mtk_eth.h -@@ -15,27 +15,38 @@ - enum mkt_eth_capabilities { - MTK_TRGMII_BIT, - MTK_TRGMII_MT7621_CLK_BIT, -+ MTK_U3_COPHY_V2_BIT, -+ MTK_INFRA_BIT, - MTK_NETSYS_V2_BIT, - - /* PATH BITS */ - MTK_ETH_PATH_GMAC1_TRGMII_BIT, -+ MTK_ETH_PATH_GMAC2_SGMII_BIT, - }; - - #define MTK_TRGMII BIT(MTK_TRGMII_BIT) - #define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT) -+#define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT) -+#define MTK_INFRA BIT(MTK_INFRA_BIT) - #define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT) - - /* Supported path present on SoCs */ - #define MTK_ETH_PATH_GMAC1_TRGMII BIT(MTK_ETH_PATH_GMAC1_TRGMII_BIT) - -+#define MTK_ETH_PATH_GMAC2_SGMII BIT(MTK_ETH_PATH_GMAC2_SGMII_BIT) -+ - #define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII) - -+#define MTK_GMAC2_U3_QPHY (MTK_ETH_PATH_GMAC2_SGMII | MTK_U3_COPHY_V2 | MTK_INFRA) -+ - #define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) - - #define MT7621_CAPS (MTK_GMAC1_TRGMII | MTK_TRGMII_MT7621_CLK) - - #define MT7623_CAPS (MTK_GMAC1_TRGMII) - -+#define MT7981_CAPS (MTK_GMAC2_U3_QPHY | MTK_NETSYS_V2) -+ - #define MT7986_CAPS (MTK_NETSYS_V2) - - /* Frame Engine Register Bases */ -@@ -56,6 +67,11 @@ enum mkt_eth_capabilities { - #define ETHSYS_CLKCFG0_REG 0x2c - #define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11) - -+/* Top misc registers */ -+#define USB_PHY_SWITCH_REG 0x218 -+#define QPHY_SEL_MASK 0x3 -+#define SGMII_QPHY_SEL 0x2 -+ - /* SYSCFG0_GE_MODE: GE Modes */ - #define GE_MODE_RGMII 0 - #define GE_MODE_MII 1 diff --git a/package/boot/uboot-mediatek/patches/101-23-arm-dts-mediatek-add-infracfg-registers-to-support-G.patch b/package/boot/uboot-mediatek/patches/101-23-arm-dts-mediatek-add-infracfg-registers-to-support-G.patch deleted file mode 100644 index 63c25304a06cdc..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-23-arm-dts-mediatek-add-infracfg-registers-to-support-G.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 64dab5fc8405005a78bdf1e0035d8b754cdf0c7e Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:27 +0800 -Subject: [PATCH 23/29] arm: dts: mediatek: add infracfg registers to support - GMAC/USB3 Co-PHY - -This patch adds infracfg to eth node to support enabling GMAC2. - -Signed-off-by: Weijie Gao ---- - arch/arm/dts/mt7981.dtsi | 7 +++++++ - 1 file changed, 7 insertions(+) - ---- a/arch/arm/dts/mt7981.dtsi -+++ b/arch/arm/dts/mt7981.dtsi -@@ -266,6 +266,7 @@ - reset-names = "fe"; - mediatek,ethsys = <ðsys>; - mediatek,sgmiisys = <&sgmiisys0>; -+ mediatek,infracfg = <&topmisc>; - #address-cells = <1>; - #size-cells = <0>; - status = "disabled"; -@@ -284,6 +285,12 @@ - #clock-cells = <1>; - }; - -+ topmisc: topmisc@11d10000 { -+ compatible = "mediatek,mt7981-topmisc", "syscon"; -+ reg = <0x11d10000 0x10000>; -+ #clock-cells = <1>; -+ }; -+ - spi0: spi@1100a000 { - compatible = "mediatek,ipm-spi"; - reg = <0x1100a000 0x100>; diff --git a/package/boot/uboot-mediatek/patches/101-24-net-mediatek-add-USXGMII-support.patch b/package/boot/uboot-mediatek/patches/101-24-net-mediatek-add-USXGMII-support.patch deleted file mode 100644 index 67288c749e4435..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-24-net-mediatek-add-USXGMII-support.patch +++ /dev/null @@ -1,341 +0,0 @@ -From d62b483092035bc86d1db83ea4ac29bfa7bba77d Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:31 +0800 -Subject: [PATCH 24/29] net: mediatek: add USXGMII support - -This patch adds support for USXGMII of SoC. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 230 +++++++++++++++++++++++++++++++++++++++++- - drivers/net/mtk_eth.h | 24 +++++ - 2 files changed, 251 insertions(+), 3 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -105,6 +105,11 @@ struct mtk_eth_priv { - - struct regmap *infra_regmap; - -+ struct regmap *usxgmii_regmap; -+ struct regmap *xfi_pextp_regmap; -+ struct regmap *xfi_pll_regmap; -+ struct regmap *toprgu_regmap; -+ - struct mii_dev *mdio_bus; - int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg); - int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val); -@@ -989,6 +994,42 @@ static int mt753x_switch_init(struct mtk - return 0; - } - -+static void mtk_xphy_link_adjust(struct mtk_eth_priv *priv) -+{ -+ u16 lcl_adv = 0, rmt_adv = 0; -+ u8 flowctrl; -+ u32 mcr; -+ -+ mcr = mtk_gmac_read(priv, XGMAC_PORT_MCR(priv->gmac_id)); -+ mcr &= ~(XGMAC_FORCE_TX_FC | XGMAC_FORCE_RX_FC); -+ -+ if (priv->phydev->duplex) { -+ if (priv->phydev->pause) -+ rmt_adv = LPA_PAUSE_CAP; -+ if (priv->phydev->asym_pause) -+ rmt_adv |= LPA_PAUSE_ASYM; -+ -+ if (priv->phydev->advertising & ADVERTISED_Pause) -+ lcl_adv |= ADVERTISE_PAUSE_CAP; -+ if (priv->phydev->advertising & ADVERTISED_Asym_Pause) -+ lcl_adv |= ADVERTISE_PAUSE_ASYM; -+ -+ flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv); -+ -+ if (flowctrl & FLOW_CTRL_TX) -+ mcr |= XGMAC_FORCE_TX_FC; -+ if (flowctrl & FLOW_CTRL_RX) -+ mcr |= XGMAC_FORCE_RX_FC; -+ -+ debug("rx pause %s, tx pause %s\n", -+ flowctrl & FLOW_CTRL_RX ? "enabled" : "disabled", -+ flowctrl & FLOW_CTRL_TX ? "enabled" : "disabled"); -+ } -+ -+ mcr &= ~(XGMAC_TRX_DISABLE); -+ mtk_gmac_write(priv, XGMAC_PORT_MCR(priv->gmac_id), mcr); -+} -+ - static void mtk_phy_link_adjust(struct mtk_eth_priv *priv) - { - u16 lcl_adv = 0, rmt_adv = 0; -@@ -1063,8 +1104,12 @@ static int mtk_phy_start(struct mtk_eth_ - return 0; - } - -- if (!priv->force_mode) -- mtk_phy_link_adjust(priv); -+ if (!priv->force_mode) { -+ if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII) -+ mtk_xphy_link_adjust(priv); -+ else -+ mtk_phy_link_adjust(priv); -+ } - - debug("Speed: %d, %s duplex%s\n", phydev->speed, - (phydev->duplex) ? "full" : "half", -@@ -1140,6 +1185,112 @@ static void mtk_sgmii_force_init(struct - SGMII_PHYA_PWD, 0); - } - -+static void mtk_xfi_pll_enable(struct mtk_eth_priv *priv) -+{ -+ u32 val = 0; -+ -+ /* Add software workaround for USXGMII PLL TCL issue */ -+ regmap_write(priv->xfi_pll_regmap, XFI_PLL_ANA_GLB8, -+ RG_XFI_PLL_ANA_SWWA); -+ -+ regmap_read(priv->xfi_pll_regmap, XFI_PLL_DIG_GLB8, &val); -+ val |= RG_XFI_PLL_EN; -+ regmap_write(priv->xfi_pll_regmap, XFI_PLL_DIG_GLB8, val); -+} -+ -+static void mtk_usxgmii_reset(struct mtk_eth_priv *priv) -+{ -+ switch (priv->gmac_id) { -+ case 1: -+ regmap_write(priv->toprgu_regmap, 0xFC, 0x0000A004); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x88F0A004); -+ regmap_write(priv->toprgu_regmap, 0xFC, 0x00000000); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x88F00000); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x00F00000); -+ break; -+ case 2: -+ regmap_write(priv->toprgu_regmap, 0xFC, 0x00005002); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x88F05002); -+ regmap_write(priv->toprgu_regmap, 0xFC, 0x00000000); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x88F00000); -+ regmap_write(priv->toprgu_regmap, 0x18, 0x00F00000); -+ break; -+ } -+ -+ mdelay(10); -+} -+ -+static void mtk_usxgmii_setup_phya_an_10000(struct mtk_eth_priv *priv) -+{ -+ regmap_write(priv->usxgmii_regmap, 0x810, 0x000FFE6D); -+ regmap_write(priv->usxgmii_regmap, 0x818, 0x07B1EC7B); -+ regmap_write(priv->usxgmii_regmap, 0x80C, 0x30000000); -+ ndelay(1020); -+ regmap_write(priv->usxgmii_regmap, 0x80C, 0x10000000); -+ ndelay(1020); -+ regmap_write(priv->usxgmii_regmap, 0x80C, 0x00000000); -+ -+ regmap_write(priv->xfi_pextp_regmap, 0x9024, 0x00C9071C); -+ regmap_write(priv->xfi_pextp_regmap, 0x2020, 0xAA8585AA); -+ regmap_write(priv->xfi_pextp_regmap, 0x2030, 0x0C020707); -+ regmap_write(priv->xfi_pextp_regmap, 0x2034, 0x0E050F0F); -+ regmap_write(priv->xfi_pextp_regmap, 0x2040, 0x00140032); -+ regmap_write(priv->xfi_pextp_regmap, 0x50F0, 0x00C014AA); -+ regmap_write(priv->xfi_pextp_regmap, 0x50E0, 0x3777C12B); -+ regmap_write(priv->xfi_pextp_regmap, 0x506C, 0x005F9CFF); -+ regmap_write(priv->xfi_pextp_regmap, 0x5070, 0x9D9DFAFA); -+ regmap_write(priv->xfi_pextp_regmap, 0x5074, 0x27273F3F); -+ regmap_write(priv->xfi_pextp_regmap, 0x5078, 0xA7883C68); -+ regmap_write(priv->xfi_pextp_regmap, 0x507C, 0x11661166); -+ regmap_write(priv->xfi_pextp_regmap, 0x5080, 0x0E000AAF); -+ regmap_write(priv->xfi_pextp_regmap, 0x5084, 0x08080D0D); -+ regmap_write(priv->xfi_pextp_regmap, 0x5088, 0x02030909); -+ regmap_write(priv->xfi_pextp_regmap, 0x50E4, 0x0C0C0000); -+ regmap_write(priv->xfi_pextp_regmap, 0x50E8, 0x04040000); -+ regmap_write(priv->xfi_pextp_regmap, 0x50EC, 0x0F0F0C06); -+ regmap_write(priv->xfi_pextp_regmap, 0x50A8, 0x506E8C8C); -+ regmap_write(priv->xfi_pextp_regmap, 0x6004, 0x18190000); -+ regmap_write(priv->xfi_pextp_regmap, 0x00F8, 0x01423342); -+ regmap_write(priv->xfi_pextp_regmap, 0x00F4, 0x80201F20); -+ regmap_write(priv->xfi_pextp_regmap, 0x0030, 0x00050C00); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x02002800); -+ ndelay(1020); -+ regmap_write(priv->xfi_pextp_regmap, 0x30B0, 0x00000020); -+ regmap_write(priv->xfi_pextp_regmap, 0x3028, 0x00008A01); -+ regmap_write(priv->xfi_pextp_regmap, 0x302C, 0x0000A884); -+ regmap_write(priv->xfi_pextp_regmap, 0x3024, 0x00083002); -+ regmap_write(priv->xfi_pextp_regmap, 0x3010, 0x00022220); -+ regmap_write(priv->xfi_pextp_regmap, 0x5064, 0x0F020A01); -+ regmap_write(priv->xfi_pextp_regmap, 0x50B4, 0x06100600); -+ regmap_write(priv->xfi_pextp_regmap, 0x3048, 0x40704000); -+ regmap_write(priv->xfi_pextp_regmap, 0x3050, 0xA8000000); -+ regmap_write(priv->xfi_pextp_regmap, 0x3054, 0x000000AA); -+ regmap_write(priv->xfi_pextp_regmap, 0x306C, 0x00000F00); -+ regmap_write(priv->xfi_pextp_regmap, 0xA060, 0x00040000); -+ regmap_write(priv->xfi_pextp_regmap, 0x90D0, 0x00000001); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x0200E800); -+ udelay(150); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x0200C111); -+ ndelay(1020); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x0200C101); -+ udelay(15); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x0202C111); -+ ndelay(1020); -+ regmap_write(priv->xfi_pextp_regmap, 0x0070, 0x0202C101); -+ udelay(100); -+ regmap_write(priv->xfi_pextp_regmap, 0x30B0, 0x00000030); -+ regmap_write(priv->xfi_pextp_regmap, 0x00F4, 0x80201F00); -+ regmap_write(priv->xfi_pextp_regmap, 0x3040, 0x30000000); -+ udelay(400); -+} -+ -+static void mtk_usxgmii_an_init(struct mtk_eth_priv *priv) -+{ -+ mtk_xfi_pll_enable(priv); -+ mtk_usxgmii_reset(priv); -+ mtk_usxgmii_setup_phya_an_10000(priv); -+} -+ - static void mtk_mac_init(struct mtk_eth_priv *priv) - { - int i, ge_mode = 0; -@@ -1222,6 +1373,36 @@ static void mtk_mac_init(struct mtk_eth_ - } - } - -+static void mtk_xmac_init(struct mtk_eth_priv *priv) -+{ -+ u32 sts; -+ -+ switch (priv->phy_interface) { -+ case PHY_INTERFACE_MODE_USXGMII: -+ mtk_usxgmii_an_init(priv); -+ break; -+ default: -+ break; -+ } -+ -+ /* Set GMAC to the correct mode */ -+ mtk_ethsys_rmw(priv, ETHSYS_SYSCFG0_REG, -+ SYSCFG0_GE_MODE_M << SYSCFG0_GE_MODE_S(priv->gmac_id), -+ 0); -+ -+ if (priv->gmac_id == 1) { -+ mtk_infra_rmw(priv, TOPMISC_NETSYS_PCS_MUX, -+ NETSYS_PCS_MUX_MASK, MUX_G2_USXGMII_SEL); -+ } else if (priv->gmac_id == 2) { -+ sts = mtk_gmac_read(priv, XGMAC_STS(priv->gmac_id)); -+ sts |= XGMAC_FORCE_LINK; -+ mtk_gmac_write(priv, XGMAC_STS(priv->gmac_id), sts); -+ } -+ -+ /* Force GMAC link down */ -+ mtk_gmac_write(priv, GMAC_PORT_MCR(priv->gmac_id), FORCE_MODE); -+} -+ - static void mtk_eth_fifo_init(struct mtk_eth_priv *priv) - { - char *pkt_base = priv->pkt_pool; -@@ -1463,7 +1644,10 @@ static int mtk_eth_probe(struct udevice - ARCH_DMA_MINALIGN); - - /* Set MAC mode */ -- mtk_mac_init(priv); -+ if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII) -+ mtk_xmac_init(priv); -+ else -+ mtk_mac_init(priv); - - /* Probe phy if switch is not specified */ - if (priv->sw == SW_NONE) -@@ -1581,6 +1765,46 @@ static int mtk_eth_of_to_plat(struct ude - } - - priv->pn_swap = ofnode_read_bool(args.node, "pn_swap"); -+ } else if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII) { -+ /* get corresponding usxgmii phandle */ -+ ret = dev_read_phandle_with_args(dev, "mediatek,usxgmiisys", -+ NULL, 0, 0, &args); -+ if (ret) -+ return ret; -+ -+ priv->usxgmii_regmap = syscon_node_to_regmap(args.node); -+ if (IS_ERR(priv->usxgmii_regmap)) -+ return PTR_ERR(priv->usxgmii_regmap); -+ -+ /* get corresponding xfi_pextp phandle */ -+ ret = dev_read_phandle_with_args(dev, "mediatek,xfi_pextp", -+ NULL, 0, 0, &args); -+ if (ret) -+ return ret; -+ -+ priv->xfi_pextp_regmap = syscon_node_to_regmap(args.node); -+ if (IS_ERR(priv->xfi_pextp_regmap)) -+ return PTR_ERR(priv->xfi_pextp_regmap); -+ -+ /* get corresponding xfi_pll phandle */ -+ ret = dev_read_phandle_with_args(dev, "mediatek,xfi_pll", -+ NULL, 0, 0, &args); -+ if (ret) -+ return ret; -+ -+ priv->xfi_pll_regmap = syscon_node_to_regmap(args.node); -+ if (IS_ERR(priv->xfi_pll_regmap)) -+ return PTR_ERR(priv->xfi_pll_regmap); -+ -+ /* get corresponding toprgu phandle */ -+ ret = dev_read_phandle_with_args(dev, "mediatek,toprgu", -+ NULL, 0, 0, &args); -+ if (ret) -+ return ret; -+ -+ priv->toprgu_regmap = syscon_node_to_regmap(args.node); -+ if (IS_ERR(priv->toprgu_regmap)) -+ return PTR_ERR(priv->toprgu_regmap); - } - - /* check for switch first, otherwise phy will be used */ ---- a/drivers/net/mtk_eth.h -+++ b/drivers/net/mtk_eth.h -@@ -68,6 +68,11 @@ enum mkt_eth_capabilities { - #define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11) - - /* Top misc registers */ -+#define TOPMISC_NETSYS_PCS_MUX 0x84 -+#define NETSYS_PCS_MUX_MASK GENMASK(1, 0) -+#define MUX_G2_USXGMII_SEL BIT(1) -+#define MUX_HSGMII1_G1_SEL BIT(0) -+ - #define USB_PHY_SWITCH_REG 0x218 - #define QPHY_SEL_MASK 0x3 - #define SGMII_QPHY_SEL 0x2 -@@ -98,6 +103,15 @@ enum mkt_eth_capabilities { - #define SGMSYS_GEN2_SPEED_V2 0x128 - #define SGMSYS_SPEED_2500 BIT(2) - -+/* USXGMII subsystem config registers */ -+/* Register to control USXGMII XFI PLL digital */ -+#define XFI_PLL_DIG_GLB8 0x08 -+#define RG_XFI_PLL_EN BIT(31) -+ -+/* Register to control USXGMII XFI PLL analog */ -+#define XFI_PLL_ANA_GLB8 0x108 -+#define RG_XFI_PLL_ANA_SWWA 0x02283248 -+ - /* Frame Engine Registers */ - #define FE_GLO_MISC_REG 0x124 - #define PDMA_VER_V2 BIT(4) -@@ -221,6 +235,16 @@ enum mkt_eth_capabilities { - #define TD_DM_DRVP_S 0 - #define TD_DM_DRVP_M 0x0f - -+/* XGMAC Status Registers */ -+#define XGMAC_STS(x) (((x) == 2) ? 0x001C : 0x000C) -+#define XGMAC_FORCE_LINK BIT(15) -+ -+/* XGMAC Registers */ -+#define XGMAC_PORT_MCR(x) (0x2000 + (((x) - 1) * 0x1000)) -+#define XGMAC_TRX_DISABLE 0xf -+#define XGMAC_FORCE_TX_FC BIT(5) -+#define XGMAC_FORCE_RX_FC BIT(4) -+ - /* MT7530 Registers */ - - #define PCR_REG(p) (0x2004 + (p) * 0x100) diff --git a/package/boot/uboot-mediatek/patches/101-25-net-mediatek-add-support-for-NETSYS-v3.patch b/package/boot/uboot-mediatek/patches/101-25-net-mediatek-add-support-for-NETSYS-v3.patch deleted file mode 100644 index 691b59faed8ec4..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-25-net-mediatek-add-support-for-NETSYS-v3.patch +++ /dev/null @@ -1,221 +0,0 @@ -From 7d201749cc49a58fb5e791d1e099ec3e3489e16d Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:37 +0800 -Subject: [PATCH 25/29] net: mediatek: add support for NETSYS v3 - -This patch adds support for NETSYS v3 hardware. -Comparing to NETSYS v2, NETSYS v3 has three GMACs. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 49 ++++++++++++++++++++++++++++++++----------- - drivers/net/mtk_eth.h | 7 +++++++ - 2 files changed, 44 insertions(+), 12 deletions(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -76,6 +76,7 @@ enum mtk_switch { - * @caps Flags shown the extra capability for the SoC - * @ana_rgc3: The offset for register ANA_RGC3 related to - * sgmiisys syscon -+ * @gdma_count: Number of GDMAs - * @pdma_base: Register base of PDMA block - * @txd_size: Tx DMA descriptor size. - * @rxd_size: Rx DMA descriptor size. -@@ -83,6 +84,7 @@ enum mtk_switch { - struct mtk_soc_data { - u32 caps; - u32 ana_rgc3; -+ u32 gdma_count; - u32 pdma_base; - u32 txd_size; - u32 rxd_size; -@@ -159,7 +161,9 @@ static void mtk_gdma_write(struct mtk_et - { - u32 gdma_base; - -- if (no == 1) -+ if (no == 2) -+ gdma_base = GDMA3_BASE; -+ else if (no == 1) - gdma_base = GDMA2_BASE; - else - gdma_base = GDMA1_BASE; -@@ -1429,7 +1433,10 @@ static void mtk_eth_fifo_init(struct mtk - txd->txd1 = virt_to_phys(pkt_base); - txd->txd2 = PDMA_TXD2_DDONE | PDMA_TXD2_LS0; - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) -+ txd->txd5 = PDMA_V2_TXD5_FPORT_SET(priv->gmac_id == 2 ? -+ 15 : priv->gmac_id + 1); -+ else if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) - txd->txd5 = PDMA_V2_TXD5_FPORT_SET(priv->gmac_id + 1); - else - txd->txd4 = PDMA_V1_TXD4_FPORT_SET(priv->gmac_id + 1); -@@ -1442,7 +1449,8 @@ static void mtk_eth_fifo_init(struct mtk - - rxd->rxd1 = virt_to_phys(pkt_base); - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2) || -+ MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) - rxd->rxd2 = PDMA_V2_RXD2_PLEN0_SET(PKTSIZE_ALIGN); - else - rxd->rxd2 = PDMA_V1_RXD2_PLEN0_SET(PKTSIZE_ALIGN); -@@ -1466,7 +1474,7 @@ static void mtk_eth_fifo_init(struct mtk - static int mtk_eth_start(struct udevice *dev) - { - struct mtk_eth_priv *priv = dev_get_priv(dev); -- int ret; -+ int i, ret; - - /* Reset FE */ - reset_assert(&priv->rst_fe); -@@ -1474,16 +1482,24 @@ static int mtk_eth_start(struct udevice - reset_deassert(&priv->rst_fe); - mdelay(10); - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2) || -+ MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) - setbits_le32(priv->fe_base + FE_GLO_MISC_REG, PDMA_VER_V2); - - /* Packets forward to PDMA */ - mtk_gdma_write(priv, priv->gmac_id, GDMA_IG_CTRL_REG, GDMA_FWD_TO_CPU); - -- if (priv->gmac_id == 0) -- mtk_gdma_write(priv, 1, GDMA_IG_CTRL_REG, GDMA_FWD_DISCARD); -- else -- mtk_gdma_write(priv, 0, GDMA_IG_CTRL_REG, GDMA_FWD_DISCARD); -+ for (i = 0; i < priv->soc->gdma_count; i++) { -+ if (i == priv->gmac_id) -+ continue; -+ -+ mtk_gdma_write(priv, i, GDMA_IG_CTRL_REG, GDMA_FWD_DISCARD); -+ } -+ -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) { -+ mtk_gdma_write(priv, priv->gmac_id, GDMA_EG_CTRL_REG, -+ GDMA_CPU_BRIDGE_EN); -+ } - - udelay(500); - -@@ -1557,7 +1573,8 @@ static int mtk_eth_send(struct udevice * - flush_dcache_range((ulong)pkt_base, (ulong)pkt_base + - roundup(length, ARCH_DMA_MINALIGN)); - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2) || -+ MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) - txd->txd2 = PDMA_TXD2_LS0 | PDMA_V2_TXD2_SDL0_SET(length); - else - txd->txd2 = PDMA_TXD2_LS0 | PDMA_V1_TXD2_SDL0_SET(length); -@@ -1583,7 +1600,8 @@ static int mtk_eth_recv(struct udevice * - return -EAGAIN; - } - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2) || -+ MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) - length = PDMA_V2_RXD2_PLEN0_GET(rxd->rxd2); - else - length = PDMA_V1_RXD2_PLEN0_GET(rxd->rxd2); -@@ -1606,7 +1624,8 @@ static int mtk_eth_free_pkt(struct udevi - - rxd = priv->rx_ring_noc + idx * priv->soc->rxd_size; - -- if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2)) -+ if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V2) || -+ MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) - rxd->rxd2 = PDMA_V2_RXD2_PLEN0_SET(PKTSIZE_ALIGN); - else - rxd->rxd2 = PDMA_V1_RXD2_PLEN0_SET(PKTSIZE_ALIGN); -@@ -1863,6 +1882,7 @@ static int mtk_eth_of_to_plat(struct ude - static const struct mtk_soc_data mt7986_data = { - .caps = MT7986_CAPS, - .ana_rgc3 = 0x128, -+ .gdma_count = 2, - .pdma_base = PDMA_V2_BASE, - .txd_size = sizeof(struct mtk_tx_dma_v2), - .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -1871,6 +1891,7 @@ static const struct mtk_soc_data mt7986_ - static const struct mtk_soc_data mt7981_data = { - .caps = MT7981_CAPS, - .ana_rgc3 = 0x128, -+ .gdma_count = 2, - .pdma_base = PDMA_V2_BASE, - .txd_size = sizeof(struct mtk_tx_dma_v2), - .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -1878,6 +1899,7 @@ static const struct mtk_soc_data mt7981_ - - static const struct mtk_soc_data mt7629_data = { - .ana_rgc3 = 0x128, -+ .gdma_count = 2, - .pdma_base = PDMA_V1_BASE, - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), -@@ -1885,6 +1907,7 @@ static const struct mtk_soc_data mt7629_ - - static const struct mtk_soc_data mt7623_data = { - .caps = MT7623_CAPS, -+ .gdma_count = 2, - .pdma_base = PDMA_V1_BASE, - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), -@@ -1892,6 +1915,7 @@ static const struct mtk_soc_data mt7623_ - - static const struct mtk_soc_data mt7622_data = { - .ana_rgc3 = 0x2028, -+ .gdma_count = 2, - .pdma_base = PDMA_V1_BASE, - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), -@@ -1899,6 +1923,7 @@ static const struct mtk_soc_data mt7622_ - - static const struct mtk_soc_data mt7621_data = { - .caps = MT7621_CAPS, -+ .gdma_count = 2, - .pdma_base = PDMA_V1_BASE, - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), ---- a/drivers/net/mtk_eth.h -+++ b/drivers/net/mtk_eth.h -@@ -18,6 +18,7 @@ enum mkt_eth_capabilities { - MTK_U3_COPHY_V2_BIT, - MTK_INFRA_BIT, - MTK_NETSYS_V2_BIT, -+ MTK_NETSYS_V3_BIT, - - /* PATH BITS */ - MTK_ETH_PATH_GMAC1_TRGMII_BIT, -@@ -29,6 +30,7 @@ enum mkt_eth_capabilities { - #define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT) - #define MTK_INFRA BIT(MTK_INFRA_BIT) - #define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT) -+#define MTK_NETSYS_V3 BIT(MTK_NETSYS_V3_BIT) - - /* Supported path present on SoCs */ - #define MTK_ETH_PATH_GMAC1_TRGMII BIT(MTK_ETH_PATH_GMAC1_TRGMII_BIT) -@@ -52,8 +54,10 @@ enum mkt_eth_capabilities { - /* Frame Engine Register Bases */ - #define PDMA_V1_BASE 0x0800 - #define PDMA_V2_BASE 0x6000 -+#define PDMA_V3_BASE 0x6800 - #define GDMA1_BASE 0x0500 - #define GDMA2_BASE 0x1500 -+#define GDMA3_BASE 0x0540 - #define GMAC_BASE 0x10000 - - /* Ethernet subsystem registers */ -@@ -153,6 +157,9 @@ enum mkt_eth_capabilities { - #define UN_DP_S 0 - #define UN_DP_M 0x0f - -+#define GDMA_EG_CTRL_REG 0x004 -+#define GDMA_CPU_BRIDGE_EN BIT(31) -+ - #define GDMA_MAC_LSB_REG 0x008 - - #define GDMA_MAC_MSB_REG 0x00c diff --git a/package/boot/uboot-mediatek/patches/101-26-net-mediatek-add-support-for-MediaTek-MT7988-SoC.patch b/package/boot/uboot-mediatek/patches/101-26-net-mediatek-add-support-for-MediaTek-MT7988-SoC.patch deleted file mode 100644 index 29e86490521502..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-26-net-mediatek-add-support-for-MediaTek-MT7988-SoC.patch +++ /dev/null @@ -1,327 +0,0 @@ -From 59dba9d87c9caf04a5d797af46699055a53870f4 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:41 +0800 -Subject: [PATCH 26/29] net: mediatek: add support for MediaTek MT7988 SoC - -This patch adds support for MediaTek MT7988. - -MT7988 features MediaTek NETSYS v3, including three GMACs, and two -of them supports 10Gbps USXGMII. - -MT7988 embeds a MT7531 switch (not MCM) which supports accessing -internal registers through MMIO instead of MDIO. - -Signed-off-by: Weijie Gao ---- - drivers/net/mtk_eth.c | 158 +++++++++++++++++++++++++++++++++++++++++- - drivers/net/mtk_eth.h | 20 ++++++ - 2 files changed, 177 insertions(+), 1 deletion(-) - ---- a/drivers/net/mtk_eth.c -+++ b/drivers/net/mtk_eth.c -@@ -54,6 +54,16 @@ - (DP_PDMA << MC_DP_S) | \ - (DP_PDMA << UN_DP_S)) - -+#define GDMA_BRIDGE_TO_CPU \ -+ (0xC0000000 | \ -+ GDM_ICS_EN | \ -+ GDM_TCS_EN | \ -+ GDM_UCS_EN | \ -+ (DP_PDMA << MYMAC_DP_S) | \ -+ (DP_PDMA << BC_DP_S) | \ -+ (DP_PDMA << MC_DP_S) | \ -+ (DP_PDMA << UN_DP_S)) -+ - #define GDMA_FWD_DISCARD \ - (0x20000000 | \ - GDM_ICS_EN | \ -@@ -68,7 +78,8 @@ - enum mtk_switch { - SW_NONE, - SW_MT7530, -- SW_MT7531 -+ SW_MT7531, -+ SW_MT7988, - }; - - /* struct mtk_soc_data - This is the structure holding all differences -@@ -102,6 +113,7 @@ struct mtk_eth_priv { - void __iomem *fe_base; - void __iomem *gmac_base; - void __iomem *sgmii_base; -+ void __iomem *gsw_base; - - struct regmap *ethsys_regmap; - -@@ -171,6 +183,11 @@ static void mtk_gdma_write(struct mtk_et - writel(val, priv->fe_base + gdma_base + reg); - } - -+static void mtk_fe_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set) -+{ -+ clrsetbits_le32(priv->fe_base + reg, clr, set); -+} -+ - static u32 mtk_gmac_read(struct mtk_eth_priv *priv, u32 reg) - { - return readl(priv->gmac_base + reg); -@@ -208,6 +225,16 @@ static void mtk_infra_rmw(struct mtk_eth - regmap_write(priv->infra_regmap, reg, val); - } - -+static u32 mtk_gsw_read(struct mtk_eth_priv *priv, u32 reg) -+{ -+ return readl(priv->gsw_base + reg); -+} -+ -+static void mtk_gsw_write(struct mtk_eth_priv *priv, u32 reg, u32 val) -+{ -+ writel(val, priv->gsw_base + reg); -+} -+ - /* Direct MDIO clause 22/45 access via SoC */ - static int mtk_mii_rw(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 data, - u32 cmd, u32 st) -@@ -342,6 +369,11 @@ static int mt753x_reg_read(struct mtk_et - { - int ret, low_word, high_word; - -+ if (priv->sw == SW_MT7988) { -+ *data = mtk_gsw_read(priv, reg); -+ return 0; -+ } -+ - /* Write page address */ - ret = mtk_mii_write(priv, priv->mt753x_smi_addr, 0x1f, reg >> 6); - if (ret) -@@ -367,6 +399,11 @@ static int mt753x_reg_write(struct mtk_e - { - int ret; - -+ if (priv->sw == SW_MT7988) { -+ mtk_gsw_write(priv, reg, data); -+ return 0; -+ } -+ - /* Write page address */ - ret = mtk_mii_write(priv, priv->mt753x_smi_addr, 0x1f, reg >> 6); - if (ret) -@@ -537,6 +574,7 @@ static int mtk_mdio_register(struct udev - priv->mmd_write = mtk_mmd_ind_write; - break; - case SW_MT7531: -+ case SW_MT7988: - priv->mii_read = mt7531_mii_ind_read; - priv->mii_write = mt7531_mii_ind_write; - priv->mmd_read = mt7531_mmd_ind_read; -@@ -957,6 +995,103 @@ static int mt7531_setup(struct mtk_eth_p - return 0; - } - -+static void mt7988_phy_setting(struct mtk_eth_priv *priv) -+{ -+ u16 val; -+ u32 i; -+ -+ for (i = 0; i < MT753X_NUM_PHYS; i++) { -+ /* Enable HW auto downshift */ -+ priv->mii_write(priv, i, 0x1f, 0x1); -+ val = priv->mii_read(priv, i, PHY_EXT_REG_14); -+ val |= PHY_EN_DOWN_SHFIT; -+ priv->mii_write(priv, i, PHY_EXT_REG_14, val); -+ -+ /* PHY link down power saving enable */ -+ val = priv->mii_read(priv, i, PHY_EXT_REG_17); -+ val |= PHY_LINKDOWN_POWER_SAVING_EN; -+ priv->mii_write(priv, i, PHY_EXT_REG_17, val); -+ } -+} -+ -+static void mt7988_mac_control(struct mtk_eth_priv *priv, bool enable) -+{ -+ u32 pmcr = FORCE_MODE_LNK; -+ -+ if (enable) -+ pmcr = priv->mt753x_pmcr; -+ -+ mt753x_reg_write(priv, PMCR_REG(6), pmcr); -+} -+ -+static int mt7988_setup(struct mtk_eth_priv *priv) -+{ -+ u16 phy_addr, phy_val; -+ u32 pmcr; -+ int i; -+ -+ priv->gsw_base = regmap_get_range(priv->ethsys_regmap, 0) + GSW_BASE; -+ -+ priv->mt753x_phy_base = (priv->mt753x_smi_addr + 1) & -+ MT753X_SMI_ADDR_MASK; -+ -+ /* Turn off PHYs */ -+ for (i = 0; i < MT753X_NUM_PHYS; i++) { -+ phy_addr = MT753X_PHY_ADDR(priv->mt753x_phy_base, i); -+ phy_val = priv->mii_read(priv, phy_addr, MII_BMCR); -+ phy_val |= BMCR_PDOWN; -+ priv->mii_write(priv, phy_addr, MII_BMCR, phy_val); -+ } -+ -+ switch (priv->phy_interface) { -+ case PHY_INTERFACE_MODE_USXGMII: -+ /* Use CPU bridge instead of actual USXGMII path */ -+ -+ /* Set GDM1 no drop */ -+ mtk_fe_rmw(priv, PSE_NO_DROP_CFG_REG, 0, PSE_NO_DROP_GDM1); -+ -+ /* Enable GDM1 to GSW CPU bridge */ -+ mtk_gmac_rmw(priv, GMAC_MAC_MISC_REG, 0, BIT(0)); -+ -+ /* XGMAC force link up */ -+ mtk_gmac_rmw(priv, GMAC_XGMAC_STS_REG, 0, P1_XGMAC_FORCE_LINK); -+ -+ /* Setup GSW CPU bridge IPG */ -+ mtk_gmac_rmw(priv, GMAC_GSW_CFG_REG, GSWTX_IPG_M | GSWRX_IPG_M, -+ (0xB << GSWTX_IPG_S) | (0xB << GSWRX_IPG_S)); -+ break; -+ default: -+ printf("Error: MT7988 GSW does not support %s interface\n", -+ phy_string_for_interface(priv->phy_interface)); -+ break; -+ } -+ -+ pmcr = MT7988_FORCE_MODE | -+ (IPG_96BIT_WITH_SHORT_IPG << IPG_CFG_S) | -+ MAC_MODE | MAC_TX_EN | MAC_RX_EN | -+ BKOFF_EN | BACKPR_EN | -+ FORCE_RX_FC | FORCE_TX_FC | -+ (SPEED_1000M << FORCE_SPD_S) | FORCE_DPX | -+ FORCE_LINK; -+ -+ priv->mt753x_pmcr = pmcr; -+ -+ /* Keep MAC link down before starting eth */ -+ mt753x_reg_write(priv, PMCR_REG(6), FORCE_MODE_LNK); -+ -+ /* Turn on PHYs */ -+ for (i = 0; i < MT753X_NUM_PHYS; i++) { -+ phy_addr = MT753X_PHY_ADDR(priv->mt753x_phy_base, i); -+ phy_val = priv->mii_read(priv, phy_addr, MII_BMCR); -+ phy_val &= ~BMCR_PDOWN; -+ priv->mii_write(priv, phy_addr, MII_BMCR, phy_val); -+ } -+ -+ mt7988_phy_setting(priv); -+ -+ return 0; -+} -+ - static int mt753x_switch_init(struct mtk_eth_priv *priv) - { - int ret; -@@ -1497,6 +1632,11 @@ static int mtk_eth_start(struct udevice - } - - if (MTK_HAS_CAPS(priv->soc->caps, MTK_NETSYS_V3)) { -+ if (priv->sw == SW_MT7988 && priv->gmac_id == 0) { -+ mtk_gdma_write(priv, priv->gmac_id, GDMA_IG_CTRL_REG, -+ GDMA_BRIDGE_TO_CPU); -+ } -+ - mtk_gdma_write(priv, priv->gmac_id, GDMA_EG_CTRL_REG, - GDMA_CPU_BRIDGE_EN); - } -@@ -1845,6 +1985,12 @@ static int mtk_eth_of_to_plat(struct ude - priv->switch_mac_control = mt7531_mac_control; - priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; - priv->mt753x_reset_wait_time = 200; -+ } else if (!strcmp(str, "mt7988")) { -+ priv->sw = SW_MT7988; -+ priv->switch_init = mt7988_setup; -+ priv->switch_mac_control = mt7988_mac_control; -+ priv->mt753x_smi_addr = MT753X_DFL_SMI_ADDR; -+ priv->mt753x_reset_wait_time = 50; - } else { - printf("error: unsupported switch\n"); - return -EINVAL; -@@ -1879,6 +2025,15 @@ static int mtk_eth_of_to_plat(struct ude - return 0; - } - -+static const struct mtk_soc_data mt7988_data = { -+ .caps = MT7988_CAPS, -+ .ana_rgc3 = 0x128, -+ .gdma_count = 3, -+ .pdma_base = PDMA_V3_BASE, -+ .txd_size = sizeof(struct mtk_tx_dma_v2), -+ .rxd_size = sizeof(struct mtk_rx_dma_v2), -+}; -+ - static const struct mtk_soc_data mt7986_data = { - .caps = MT7986_CAPS, - .ana_rgc3 = 0x128, -@@ -1930,6 +2085,7 @@ static const struct mtk_soc_data mt7621_ - }; - - static const struct udevice_id mtk_eth_ids[] = { -+ { .compatible = "mediatek,mt7988-eth", .data = (ulong)&mt7988_data }, - { .compatible = "mediatek,mt7986-eth", .data = (ulong)&mt7986_data }, - { .compatible = "mediatek,mt7981-eth", .data = (ulong)&mt7981_data }, - { .compatible = "mediatek,mt7629-eth", .data = (ulong)&mt7629_data }, ---- a/drivers/net/mtk_eth.h -+++ b/drivers/net/mtk_eth.h -@@ -51,6 +51,8 @@ enum mkt_eth_capabilities { - - #define MT7986_CAPS (MTK_NETSYS_V2) - -+#define MT7988_CAPS (MTK_NETSYS_V3 | MTK_INFRA) -+ - /* Frame Engine Register Bases */ - #define PDMA_V1_BASE 0x0800 - #define PDMA_V2_BASE 0x6000 -@@ -59,6 +61,7 @@ enum mkt_eth_capabilities { - #define GDMA2_BASE 0x1500 - #define GDMA3_BASE 0x0540 - #define GMAC_BASE 0x10000 -+#define GSW_BASE 0x20000 - - /* Ethernet subsystem registers */ - -@@ -117,6 +120,9 @@ enum mkt_eth_capabilities { - #define RG_XFI_PLL_ANA_SWWA 0x02283248 - - /* Frame Engine Registers */ -+#define PSE_NO_DROP_CFG_REG 0x108 -+#define PSE_NO_DROP_GDM1 BIT(1) -+ - #define FE_GLO_MISC_REG 0x124 - #define PDMA_VER_V2 BIT(4) - -@@ -187,6 +193,17 @@ enum mkt_eth_capabilities { - #define MDIO_RW_DATA_S 0 - #define MDIO_RW_DATA_M 0xffff - -+#define GMAC_XGMAC_STS_REG 0x000c -+#define P1_XGMAC_FORCE_LINK BIT(15) -+ -+#define GMAC_MAC_MISC_REG 0x0010 -+ -+#define GMAC_GSW_CFG_REG 0x0080 -+#define GSWTX_IPG_M 0xF0000 -+#define GSWTX_IPG_S 16 -+#define GSWRX_IPG_M 0xF -+#define GSWRX_IPG_S 0 -+ - /* MDIO_CMD: MDIO commands */ - #define MDIO_CMD_ADDR 0 - #define MDIO_CMD_WRITE 1 -@@ -285,6 +302,9 @@ enum mkt_eth_capabilities { - FORCE_MODE_TX_FC | FORCE_MODE_RX_FC | \ - FORCE_MODE_DPX | FORCE_MODE_SPD | \ - FORCE_MODE_LNK -+#define MT7988_FORCE_MODE FORCE_MODE_TX_FC | FORCE_MODE_RX_FC | \ -+ FORCE_MODE_DPX | FORCE_MODE_SPD | \ -+ FORCE_MODE_LNK - - /* MT7531 SGMII Registers */ - #define MT7531_SGMII_REG_BASE 0x5000 diff --git a/package/boot/uboot-mediatek/patches/101-27-tools-mtk_image-use-uint32_t-for-ghf-header-magic-an.patch b/package/boot/uboot-mediatek/patches/101-27-tools-mtk_image-use-uint32_t-for-ghf-header-magic-an.patch deleted file mode 100644 index 07620f77b31400..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-27-tools-mtk_image-use-uint32_t-for-ghf-header-magic-an.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 757b997f1f5a958e6fec3d5aee1ff5cdf5766711 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:45 +0800 -Subject: [PATCH 27/29] tools: mtk_image: use uint32_t for ghf header magic and - version - -This patch converts magic and version fields of ghf common header -to one field with the type of uint32_t to make this header flexible -for futher updates. - -Signed-off-by: Weijie Gao ---- - tools/mtk_image.c | 10 ++++++---- - tools/mtk_image.h | 6 +++--- - 2 files changed, 9 insertions(+), 7 deletions(-) - ---- a/tools/mtk_image.c -+++ b/tools/mtk_image.c -@@ -542,11 +542,13 @@ static void put_brom_layout_header(struc - hdr->type = cpu_to_le32(type); - } - --static void put_ghf_common_header(struct gfh_common_header *gfh, int size, -- int type, int ver) -+static void put_ghf_common_header(struct gfh_common_header *gfh, uint16_t size, -+ uint16_t type, uint8_t ver) - { -- memcpy(gfh->magic, GFH_HEADER_MAGIC, sizeof(gfh->magic)); -- gfh->version = ver; -+ uint32_t magic_version = GFH_HEADER_MAGIC | -+ (uint32_t)ver << GFH_HEADER_VERSION_SHIFT; -+ -+ gfh->magic_version = cpu_to_le32(magic_version); - gfh->size = cpu_to_le16(size); - gfh->type = cpu_to_le16(type); - } ---- a/tools/mtk_image.h -+++ b/tools/mtk_image.h -@@ -63,13 +63,13 @@ struct gen_device_header { - - /* BootROM header definitions */ - struct gfh_common_header { -- uint8_t magic[3]; -- uint8_t version; -+ uint32_t magic_version; - uint16_t size; - uint16_t type; - }; - --#define GFH_HEADER_MAGIC "MMM" -+#define GFH_HEADER_MAGIC 0x4D4D4D -+#define GFH_HEADER_VERSION_SHIFT 24 - - #define GFH_TYPE_FILE_INFO 0 - #define GFH_TYPE_BL_INFO 1 diff --git a/package/boot/uboot-mediatek/patches/101-28-arm-mediatek-add-support-for-MediaTek-MT7988-SoC.patch b/package/boot/uboot-mediatek/patches/101-28-arm-mediatek-add-support-for-MediaTek-MT7988-SoC.patch deleted file mode 100644 index f54a028b4262b8..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-28-arm-mediatek-add-support-for-MediaTek-MT7988-SoC.patch +++ /dev/null @@ -1,606 +0,0 @@ -From 884430dadcc2c5d0a2b248795001955a9fa5a1a9 Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:49 +0800 -Subject: [PATCH 28/29] arm: mediatek: add support for MediaTek MT7988 SoC - -This patch adds basic support for MediaTek MT7988 SoC. -This includes files that will initialize the SoC after boot and -its device tree. - -Signed-off-by: Weijie Gao ---- - arch/arm/dts/mt7988-u-boot.dtsi | 25 ++ - arch/arm/dts/mt7988.dtsi | 391 ++++++++++++++++++ - arch/arm/mach-mediatek/Kconfig | 13 +- - arch/arm/mach-mediatek/Makefile | 1 + - arch/arm/mach-mediatek/mt7988/Makefile | 4 + - arch/arm/mach-mediatek/mt7988/init.c | 63 +++ - arch/arm/mach-mediatek/mt7988/lowlevel_init.S | 30 ++ - 7 files changed, 526 insertions(+), 1 deletion(-) - create mode 100644 arch/arm/dts/mt7988-u-boot.dtsi - create mode 100644 arch/arm/dts/mt7988.dtsi - create mode 100644 arch/arm/mach-mediatek/mt7988/Makefile - create mode 100644 arch/arm/mach-mediatek/mt7988/init.c - create mode 100644 arch/arm/mach-mediatek/mt7988/lowlevel_init.S - ---- /dev/null -+++ b/arch/arm/dts/mt7988-u-boot.dtsi -@@ -0,0 +1,25 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (c) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+&system_clk { -+ bootph-all; -+}; -+ -+&spi_clk { -+ bootph-all; -+}; -+ -+&uart0 { -+ bootph-all; -+}; -+ -+&uart1 { -+ bootph-all; -+}; -+ -+&uart2 { -+ bootph-all; -+}; ---- /dev/null -+++ b/arch/arm/dts/mt7988.dtsi -@@ -0,0 +1,391 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (c) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+/ { -+ compatible = "mediatek,mt7988-rfb"; -+ interrupt-parent = <&gic>; -+ #address-cells = <2>; -+ #size-cells = <2>; -+ -+ cpus { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ -+ cpu0: cpu@0 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a73"; -+ reg = <0x0>; -+ mediatek,hwver = <&hwver>; -+ }; -+ -+ cpu1: cpu@1 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a73"; -+ reg = <0x1>; -+ mediatek,hwver = <&hwver>; -+ }; -+ -+ cpu2: cpu@2 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a73"; -+ reg = <0x2>; -+ mediatek,hwver = <&hwver>; -+ }; -+ -+ cpu3: cpu@3 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a73"; -+ reg = <0x3>; -+ mediatek,hwver = <&hwver>; -+ }; -+ }; -+ -+ system_clk: dummy40m { -+ compatible = "fixed-clock"; -+ clock-frequency = <40000000>; -+ #clock-cells = <0>; -+ }; -+ -+ spi_clk: dummy208m { -+ compatible = "fixed-clock"; -+ clock-frequency = <208000000>; -+ #clock-cells = <0>; -+ }; -+ -+ hwver: hwver { -+ compatible = "mediatek,hwver", "syscon"; -+ reg = <0 0x8000000 0 0x1000>; -+ }; -+ -+ timer { -+ compatible = "arm,armv8-timer"; -+ interrupt-parent = <&gic>; -+ clock-frequency = <13000000>; -+ interrupts = , -+ , -+ , -+ ; -+ }; -+ -+ watchdog: watchdog@1001c000 { -+ compatible = "mediatek,mt7622-wdt", -+ "mediatek,mt6589-wdt", -+ "syscon"; -+ reg = <0 0x1001c000 0 0x1000>; -+ interrupts = ; -+ #reset-cells = <1>; -+ }; -+ -+ gic: interrupt-controller@c000000 { -+ compatible = "arm,gic-v3"; -+ #interrupt-cells = <3>; -+ interrupt-parent = <&gic>; -+ interrupt-controller; -+ reg = <0 0x0c000000 0 0x40000>, /* GICD */ -+ <0 0x0c080000 0 0x200000>; /* GICR */ -+ interrupts = ; -+ }; -+ -+ infracfg_ao_cgs: infracfg_ao_cgs@10001000 { -+ compatible = "mediatek,mt7988-infracfg_ao_cgs", "syscon"; -+ reg = <0 0x10001000 0 0x1000>; -+ clock-parent = <&infracfg_ao>; -+ #clock-cells = <1>; -+ }; -+ -+ apmixedsys: apmixedsys@1001e000 { -+ compatible = "mediatek,mt7988-fixed-plls", "syscon"; -+ reg = <0 0x1001e000 0 0x1000>; -+ #clock-cells = <1>; -+ }; -+ -+ topckgen: topckgen@1001b000 { -+ compatible = "mediatek,mt7988-topckgen", "syscon"; -+ reg = <0 0x1001b000 0 0x1000>; -+ clock-parent = <&apmixedsys>; -+ #clock-cells = <1>; -+ }; -+ -+ pinctrl: pinctrl@1001f000 { -+ compatible = "mediatek,mt7988-pinctrl"; -+ reg = <0 0x1001f000 0 0x1000>, -+ <0 0x11c10000 0 0x1000>, -+ <0 0x11d00000 0 0x1000>, -+ <0 0x11d20000 0 0x1000>, -+ <0 0x11e00000 0 0x1000>, -+ <0 0x11f00000 0 0x1000>, -+ <0 0x1000b000 0 0x1000>; -+ reg-names = "gpio_base", "iocfg_tr_base", "iocfg_br_base", -+ "iocfg_rb_base", "iocfg_lb_base", "iocfg_tl_base", -+ "eint"; -+ gpio: gpio-controller { -+ gpio-controller; -+ #gpio-cells = <2>; -+ }; -+ }; -+ -+ sgmiisys0: syscon@10060000 { -+ compatible = "mediatek,mt7988-sgmiisys_0", "syscon"; -+ reg = <0 0x10060000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ sgmiisys1: syscon@10070000 { -+ compatible = "mediatek,mt7988-sgmiisys_1", "syscon"; -+ reg = <0 0x10070000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ usxgmiisys0: syscon@10080000 { -+ compatible = "mediatek,mt7988-usxgmiisys_0", "syscon"; -+ reg = <0 0x10080000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ usxgmiisys1: syscon@10081000 { -+ compatible = "mediatek,mt7988-usxgmiisys_1", "syscon"; -+ reg = <0 0x10081000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ xfi_pextp0: syscon@11f20000 { -+ compatible = "mediatek,mt7988-xfi_pextp_0", "syscon"; -+ reg = <0 0x11f20000 0 0x10000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ xfi_pextp1: syscon@11f30000 { -+ compatible = "mediatek,mt7988-xfi_pextp_1", "syscon"; -+ reg = <0 0x11f30000 0 0x10000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ xfi_pll: syscon@11f40000 { -+ compatible = "mediatek,mt7988-xfi_pll", "syscon"; -+ reg = <0 0x11f40000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ topmisc: topmisc@11d10000 { -+ compatible = "mediatek,mt7988-topmisc", "syscon", -+ "mediatek,mt7988-power-controller"; -+ reg = <0 0x11d10000 0 0x10000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ infracfg_ao: infracfg@10001000 { -+ compatible = "mediatek,mt7988-infracfg", "syscon"; -+ reg = <0 0x10001000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ }; -+ -+ uart0: serial@11000000 { -+ compatible = "mediatek,hsuart"; -+ reg = <0 0x11000000 0 0x100>; -+ interrupts = ; -+ clocks = <&infracfg_ao_cgs CK_INFRA_52M_UART0_CK>; -+ assigned-clocks = <&topckgen CK_TOP_UART_SEL>, -+ <&infracfg_ao CK_INFRA_MUX_UART0_SEL>; -+ assigned-clock-parents = <&topckgen CK_TOP_CB_CKSQ_40M>, -+ <&infracfg_ao CK_INFRA_UART_O0>; -+ status = "disabled"; -+ }; -+ -+ uart1: serial@11000100 { -+ compatible = "mediatek,hsuart"; -+ reg = <0 0x11000100 0 0x100>; -+ interrupts = ; -+ clocks = <&infracfg_ao_cgs CK_INFRA_52M_UART1_CK>; -+ assigned-clocks = <&topckgen CK_TOP_UART_SEL>, -+ <&infracfg_ao CK_INFRA_MUX_UART1_SEL>; -+ assigned-clock-parents = <&topckgen CK_TOP_CB_CKSQ_40M>, -+ <&infracfg_ao CK_INFRA_UART_O1>; -+ status = "disabled"; -+ }; -+ -+ uart2: serial@11000200 { -+ compatible = "mediatek,hsuart"; -+ reg = <0 0x11000200 0 0x100>; -+ interrupts = ; -+ clocks = <&infracfg_ao_cgs CK_INFRA_52M_UART2_CK>; -+ assigned-clocks = <&topckgen CK_TOP_UART_SEL>, -+ <&infracfg_ao CK_INFRA_MUX_UART2_SEL>; -+ assigned-clock-parents = <&topckgen CK_TOP_CB_CKSQ_40M>, -+ <&infracfg_ao CK_INFRA_UART_O2>; -+ status = "disabled"; -+ }; -+ -+ i2c0: i2c@11003000 { -+ compatible = "mediatek,mt7988-i2c", -+ "mediatek,mt7981-i2c"; -+ reg = <0 0x11003000 0 0x1000>, -+ <0 0x10217080 0 0x80>; -+ interrupts = ; -+ clock-div = <1>; -+ clocks = <&infracfg_ao CK_INFRA_I2C_BCK>, -+ <&infracfg_ao CK_INFRA_66M_AP_DMA_BCK>; -+ clock-names = "main", "dma"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "disabled"; -+ }; -+ -+ i2c1: i2c@11004000 { -+ compatible = "mediatek,mt7988-i2c", -+ "mediatek,mt7981-i2c"; -+ reg = <0 0x11004000 0 0x1000>, -+ <0 0x10217100 0 0x80>; -+ interrupts = ; -+ clock-div = <1>; -+ clocks = <&infracfg_ao CK_INFRA_I2C_BCK>, -+ <&infracfg_ao CK_INFRA_66M_AP_DMA_BCK>; -+ clock-names = "main", "dma"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "disabled"; -+ }; -+ -+ i2c2: i2c@11005000 { -+ compatible = "mediatek,mt7988-i2c", -+ "mediatek,mt7981-i2c"; -+ reg = <0 0x11005000 0 0x1000>, -+ <0 0x10217180 0 0x80>; -+ interrupts = ; -+ clock-div = <1>; -+ clocks = <&infracfg_ao CK_INFRA_I2C_BCK>, -+ <&infracfg_ao CK_INFRA_66M_AP_DMA_BCK>; -+ clock-names = "main", "dma"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "disabled"; -+ }; -+ -+ pwm: pwm@10048000 { -+ compatible = "mediatek,mt7988-pwm"; -+ reg = <0 0x10048000 0 0x1000>; -+ #pwm-cells = <2>; -+ clocks = <&infracfg_ao CK_INFRA_66M_PWM_BCK>, -+ <&infracfg_ao CK_INFRA_66M_PWM_HCK>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK1>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK2>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK3>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK4>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK5>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK6>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK7>, -+ <&infracfg_ao CK_INFRA_66M_PWM_CK8>; -+ clock-names = "top", "main", "pwm1", "pwm2", "pwm3", -+ "pwm4","pwm5","pwm6","pwm7","pwm8"; -+ status = "disabled"; -+ }; -+ -+ snand: snand@11001000 { -+ compatible = "mediatek,mt7988-snand", -+ "mediatek,mt7986-snand"; -+ reg = <0 0x11001000 0 0x1000>, -+ <0 0x11002000 0 0x1000>; -+ reg-names = "nfi", "ecc"; -+ interrupts = ; -+ clocks = <&infracfg_ao CK_INFRA_SPINFI>, -+ <&infracfg_ao CK_INFRA_NFI>, -+ <&infracfg_ao CK_INFRA_66M_NFI_HCK>; -+ clock-names = "pad_clk", "nfi_clk", "nfi_hclk"; -+ assigned-clocks = <&topckgen CK_TOP_SPINFI_SEL>, -+ <&topckgen CK_TOP_NFI1X_SEL>; -+ assigned-clock-parents = <&topckgen CK_TOP_CB_M_D8>, -+ <&topckgen CK_TOP_CB_M_D8>; -+ status = "disabled"; -+ }; -+ -+ spi0: spi@1100a000 { -+ compatible = "mediatek,ipm-spi"; -+ reg = <0 0x11007000 0 0x100>; -+ clocks = <&spi_clk>, -+ <&spi_clk>; -+ clock-names = "sel-clk", "spi-clk"; -+ interrupts = ; -+ status = "disabled"; -+ }; -+ -+ spi1: spi@1100b000 { -+ compatible = "mediatek,ipm-spi"; -+ reg = <0 0x11008000 0 0x100>; -+ interrupts = ; -+ status = "disabled"; -+ }; -+ -+ spi2: spi@11009000 { -+ compatible = "mediatek,ipm-spi"; -+ reg = <0 0x11009000 0 0x100>; -+ clocks = <&spi_clk>, -+ <&spi_clk>; -+ clock-names = "sel-clk", "spi-clk"; -+ interrupts = ; -+ status = "disabled"; -+ }; -+ -+ mmc0: mmc@11230000 { -+ compatible = "mediatek,mt7988-mmc", -+ "mediatek,mt7986-mmc"; -+ reg = <0 0x11230000 0 0x1000>; -+ interrupts = ; -+ clocks = <&infracfg_ao_cgs CK_INFRA_MSDC400>, -+ <&infracfg_ao_cgs CK_INFRA_MSDC2_HCK>, -+ <&infracfg_ao_cgs CK_INFRA_133M_MSDC_0_HCK>, -+ <&infracfg_ao_cgs CK_INFRA_66M_MSDC_0_HCK>; -+ clock-names = "source", "hclk", "source_cg", "axi_cg"; -+ status = "disabled"; -+ }; -+ -+ ethdma: syscon@15000000 { -+ compatible = "mediatek,mt7988-ethdma", "syscon"; -+ reg = <0 0x15000000 0 0x20000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ #reset-cells = <1>; -+ }; -+ -+ ethwarp: syscon@15031000 { -+ compatible = "mediatek,mt7988-ethwarp", "syscon"; -+ reg = <0 0x15031000 0 0x1000>; -+ clock-parent = <&topckgen>; -+ #clock-cells = <1>; -+ #reset-cells = <1>; -+ }; -+ -+ eth: ethernet@15100000 { -+ compatible = "mediatek,mt7988-eth", "syscon"; -+ reg = <0 0x15100000 0 0x20000>; -+ mediatek,ethsys = <ðdma>; -+ mediatek,sgmiisys = <&sgmiisys0>; -+ mediatek,usxgmiisys = <&usxgmiisys0>; -+ mediatek,xfi_pextp = <&xfi_pextp0>; -+ mediatek,xfi_pll = <&xfi_pll>; -+ mediatek,infracfg = <&topmisc>; -+ mediatek,toprgu = <&watchdog>; -+ resets = <ðdma ETHDMA_FE_RST>, <ðwarp ETHWARP_GSW_RST>; -+ reset-names = "fe", "mcm"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ mediatek,mcm; -+ status = "disabled"; -+ }; -+}; ---- a/arch/arm/mach-mediatek/Kconfig -+++ b/arch/arm/mach-mediatek/Kconfig -@@ -58,6 +58,15 @@ config TARGET_MT7986 - including UART, SPI, SPI flash, USB3.0, MMC, NAND, SNFI, PWM, PCIe, - Gigabit Ethernet, I2C, built-in 4x4 Wi-Fi, and PCIe. - -+config TARGET_MT7988 -+ bool "MediaTek MT7988 SoC" -+ select ARM64 -+ select CPU -+ help -+ The MediaTek MT7988 is a ARM64-based SoC with a quad-core Cortex-A73. -+ including UART, SPI, SPI flash, USB3.0, MMC, NAND, SNFI, PWM, PCIe, -+ 10 Gigabit Ethernet , I2C, and PCIe. -+ - config TARGET_MT8183 - bool "MediaTek MT8183 SoC" - select ARM64 -@@ -104,6 +113,7 @@ config SYS_BOARD - default "mt7629" if TARGET_MT7629 - default "mt7981" if TARGET_MT7981 - default "mt7986" if TARGET_MT7986 -+ default "mt7988" if TARGET_MT7988 - default "mt8183" if TARGET_MT8183 - default "mt8512" if TARGET_MT8512 - default "mt8516" if TARGET_MT8516 -@@ -121,6 +131,7 @@ config SYS_CONFIG_NAME - default "mt7629" if TARGET_MT7629 - default "mt7981" if TARGET_MT7981 - default "mt7986" if TARGET_MT7986 -+ default "mt7988" if TARGET_MT7988 - default "mt8183" if TARGET_MT8183 - default "mt8512" if TARGET_MT8512 - default "mt8516" if TARGET_MT8516 -@@ -135,7 +146,7 @@ config MTK_BROM_HEADER_INFO - string - default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7622 - default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8183 -- default "media=snand;nandinfo=2k+64" if TARGET_MT7981 || TARGET_MT7986 -+ default "media=snand;nandinfo=2k+64" if TARGET_MT7981 || TARGET_MT7986 || TARGET_MT7988 - default "lk=1" if TARGET_MT7623 - - source "board/mediatek/mt7629/Kconfig" ---- a/arch/arm/mach-mediatek/Makefile -+++ b/arch/arm/mach-mediatek/Makefile -@@ -9,6 +9,7 @@ obj-$(CONFIG_TARGET_MT7623) += mt7623/ - obj-$(CONFIG_TARGET_MT7629) += mt7629/ - obj-$(CONFIG_TARGET_MT7981) += mt7981/ - obj-$(CONFIG_TARGET_MT7986) += mt7986/ -+obj-$(CONFIG_TARGET_MT7988) += mt7988/ - obj-$(CONFIG_TARGET_MT8183) += mt8183/ - obj-$(CONFIG_TARGET_MT8516) += mt8516/ - obj-$(CONFIG_TARGET_MT8518) += mt8518/ ---- /dev/null -+++ b/arch/arm/mach-mediatek/mt7988/Makefile -@@ -0,0 +1,4 @@ -+# SPDX-License-Identifier: GPL-2.0 -+ -+obj-y += init.o -+obj-y += lowlevel_init.o ---- /dev/null -+++ b/arch/arm/mach-mediatek/mt7988/init.c -@@ -0,0 +1,63 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (C) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+DECLARE_GLOBAL_DATA_PTR; -+ -+#define SZ_8G _AC(0x200000000, ULL) -+ -+int dram_init(void) -+{ -+ int ret; -+ -+ ret = fdtdec_setup_mem_size_base(); -+ if (ret) -+ return ret; -+ -+ gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_8G); -+ -+ return 0; -+} -+ -+int dram_init_banksize(void) -+{ -+ gd->bd->bi_dram[0].start = gd->ram_base; -+ gd->bd->bi_dram[0].size = gd->ram_size; -+ -+ return 0; -+} -+ -+void reset_cpu(ulong addr) -+{ -+ psci_system_reset(); -+} -+ -+static struct mm_region mt7988_mem_map[] = { -+ { -+ /* DDR */ -+ .virt = 0x40000000UL, -+ .phys = 0x40000000UL, -+ .size = 0x200000000ULL, -+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE, -+ }, { -+ .virt = 0x00000000UL, -+ .phys = 0x00000000UL, -+ .size = 0x40000000UL, -+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | -+ PTE_BLOCK_NON_SHARE | -+ PTE_BLOCK_PXN | PTE_BLOCK_UXN -+ }, { -+ 0, -+ } -+}; -+ -+struct mm_region *mem_map = mt7988_mem_map; ---- /dev/null -+++ b/arch/arm/mach-mediatek/mt7988/lowlevel_init.S -@@ -0,0 +1,30 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+/* -+ * Copyright (C) 2020 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+/* -+ * Switch from AArch64 EL2 to AArch32 EL2 -+ * @param inputs: -+ * x0: argument, zero -+ * x1: machine nr -+ * x2: fdt address -+ * x3: input argument -+ * x4: kernel entry point -+ * @param outputs for secure firmware: -+ * x0: function id -+ * x1: kernel entry point -+ * x2: machine nr -+ * x3: fdt address -+*/ -+ -+.global armv8_el2_to_aarch32 -+armv8_el2_to_aarch32: -+ mov x3, x2 -+ mov x2, x1 -+ mov x1, x4 -+ mov x4, #0 -+ ldr x0, =0x82000200 -+ SMC #0 -+ ret diff --git a/package/boot/uboot-mediatek/patches/101-29-board-mediatek-add-MT7988-reference-boards.patch b/package/boot/uboot-mediatek/patches/101-29-board-mediatek-add-MT7988-reference-boards.patch deleted file mode 100644 index ef41f4d56a0e77..00000000000000 --- a/package/boot/uboot-mediatek/patches/101-29-board-mediatek-add-MT7988-reference-boards.patch +++ /dev/null @@ -1,575 +0,0 @@ -From fd7d9124ffa6761f27747daeea599e0ab874c1fa Mon Sep 17 00:00:00 2001 -From: Weijie Gao -Date: Wed, 19 Jul 2023 17:17:54 +0800 -Subject: [PATCH 29/29] board: mediatek: add MT7988 reference boards - -This patch adds general board files based on MT7988 SoCs. - -MT7988 uses one mmc controller for booting from both SD and eMMC, -and the pins of mmc controller booting from SD are also shared with -one of spi controllers. -So two configs are need for these boot types: - -1. mt7988_rfb_defconfig - SPI-NOR, SPI-NAND and eMMC -2. mt7988_sd_rfb_defconfig - SPI-NAND and SD - -Signed-off-by: Weijie Gao ---- - arch/arm/dts/Makefile | 2 + - arch/arm/dts/mt7988-rfb.dts | 182 +++++++++++++++++++++++++++++ - arch/arm/dts/mt7988-sd-rfb.dts | 134 +++++++++++++++++++++ - board/mediatek/mt7988/MAINTAINERS | 7 ++ - board/mediatek/mt7988/Makefile | 3 + - board/mediatek/mt7988/mt7988_rfb.c | 10 ++ - configs/mt7988_rfb_defconfig | 83 +++++++++++++ - configs/mt7988_sd_rfb_defconfig | 71 +++++++++++ - include/configs/mt7988.h | 14 +++ - 9 files changed, 506 insertions(+) - create mode 100644 arch/arm/dts/mt7988-rfb.dts - create mode 100644 arch/arm/dts/mt7988-sd-rfb.dts - create mode 100644 board/mediatek/mt7988/MAINTAINERS - create mode 100644 board/mediatek/mt7988/Makefile - create mode 100644 board/mediatek/mt7988/mt7988_rfb.c - create mode 100644 configs/mt7988_rfb_defconfig - create mode 100644 configs/mt7988_sd_rfb_defconfig - create mode 100644 include/configs/mt7988.h - ---- a/arch/arm/dts/Makefile -+++ b/arch/arm/dts/Makefile -@@ -1319,6 +1319,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ - mt7986b-sd-rfb.dtb \ - mt7986a-emmc-rfb.dtb \ - mt7986b-emmc-rfb.dtb \ -+ mt7988-rfb.dtb \ -+ mt7988-sd-rfb.dtb \ - mt8183-pumpkin.dtb \ - mt8512-bm1-emmc.dtb \ - mt8516-pumpkin.dtb \ ---- /dev/null -+++ b/arch/arm/dts/mt7988-rfb.dts -@@ -0,0 +1,182 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (c) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+/dts-v1/; -+#include "mt7988.dtsi" -+#include -+ -+/ { -+ model = "mt7988-rfb"; -+ compatible = "mediatek,mt7988-rfb"; -+ -+ chosen { -+ stdout-path = &uart0; -+ }; -+ -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0 0x40000000 0 0x10000000>; -+ }; -+ -+ reg_3p3v: regulator-3p3v { -+ compatible = "regulator-fixed"; -+ regulator-name = "fixed-3.3V"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-boot-on; -+ regulator-always-on; -+ }; -+ -+ reg_1p8v: regulator-1p8v { -+ compatible = "regulator-fixed"; -+ regulator-name = "fixed-1.8V"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-boot-on; -+ regulator-always-on; -+ }; -+}; -+ -+&uart0 { -+ status = "okay"; -+}; -+ -+&i2c1 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&i2c1_pins>; -+ status = "okay"; -+}; -+ -+ð { -+ status = "okay"; -+ mediatek,gmac-id = <0>; -+ phy-mode = "usxgmii"; -+ mediatek,switch = "mt7988"; -+ -+ fixed-link { -+ speed = <1000>; -+ full-duplex; -+ pause; -+ }; -+}; -+ -+&pinctrl { -+ i2c1_pins: i2c1-pins { -+ mux { -+ function = "i2c"; -+ groups = "i2c1_0"; -+ }; -+ }; -+ -+ pwm_pins: pwm-pins { -+ mux { -+ function = "pwm"; -+ groups = "pwm0", "pwm1", "pwm2", "pwm3", "pwm4", -+ "pwm5", "pwm6", "pwm7"; -+ }; -+ }; -+ -+ spi0_pins: spi0-pins { -+ mux { -+ function = "spi"; -+ groups = "spi0", "spi0_wp_hold"; -+ }; -+ }; -+ -+ spi2_pins: spi2-pins { -+ mux { -+ function = "spi"; -+ groups = "spi2", "spi2_wp_hold"; -+ }; -+ }; -+ -+ mmc0_pins_default: mmc0default { -+ mux { -+ function = "flash"; -+ groups = "emmc_51"; -+ }; -+ -+ conf-cmd-dat { -+ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2", -+ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5", -+ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD"; -+ input-enable; -+ }; -+ -+ conf-clk { -+ pins = "EMMC_CK"; -+ }; -+ -+ conf-dsl { -+ pins = "EMMC_DSL"; -+ }; -+ -+ conf-rst { -+ pins = "EMMC_RSTB"; -+ }; -+ }; -+}; -+ -+&pwm { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pwm_pins>; -+ status = "okay"; -+}; -+ -+&spi0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&spi0_pins>; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ must_tx; -+ enhance_timing; -+ dma_ext; -+ ipm_design; -+ support_quad; -+ tick_dly = <2>; -+ sample_sel = <0>; -+ -+ spi_nand@0 { -+ compatible = "spi-nand"; -+ reg = <0>; -+ spi-max-frequency = <52000000>; -+ }; -+}; -+ -+&spi2 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&spi2_pins>; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ must_tx; -+ enhance_timing; -+ dma_ext; -+ ipm_design; -+ support_quad; -+ tick_dly = <2>; -+ sample_sel = <0>; -+ -+ spi_nor@0 { -+ compatible = "jedec,spi-nor"; -+ reg = <0>; -+ spi-max-frequency = <52000000>; -+ }; -+}; -+ -+&mmc0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&mmc0_pins_default>; -+ max-frequency = <52000000>; -+ bus-width = <8>; -+ cap-mmc-highspeed; -+ cap-mmc-hw-reset; -+ vmmc-supply = <®_3p3v>; -+ vqmmc-supply = <®_1p8v>; -+ non-removable; -+ status = "okay"; -+}; ---- /dev/null -+++ b/arch/arm/dts/mt7988-sd-rfb.dts -@@ -0,0 +1,134 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (c) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+/dts-v1/; -+#include "mt7988.dtsi" -+#include -+ -+/ { -+ model = "mt7988-rfb"; -+ compatible = "mediatek,mt7988-rfb", "mediatek,mt7988-sd-rfb"; -+ -+ chosen { -+ stdout-path = &uart0; -+ }; -+ -+ memory@40000000 { -+ device_type = "memory"; -+ reg = <0 0x40000000 0 0x10000000>; -+ }; -+ -+ reg_3p3v: regulator-3p3v { -+ compatible = "regulator-fixed"; -+ regulator-name = "fixed-3.3V"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-boot-on; -+ regulator-always-on; -+ }; -+}; -+ -+&uart0 { -+ status = "okay"; -+}; -+ -+&i2c1 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&i2c1_pins>; -+ status = "okay"; -+}; -+ -+ð { -+ status = "okay"; -+ mediatek,gmac-id = <0>; -+ phy-mode = "usxgmii"; -+ mediatek,switch = "mt7988"; -+ -+ fixed-link { -+ speed = <1000>; -+ full-duplex; -+ pause; -+ }; -+}; -+ -+&pinctrl { -+ i2c1_pins: i2c1-pins { -+ mux { -+ function = "i2c"; -+ groups = "i2c1_0"; -+ }; -+ }; -+ -+ pwm_pins: pwm-pins { -+ mux { -+ function = "pwm"; -+ groups = "pwm0", "pwm1", "pwm2", "pwm3", "pwm4", -+ "pwm5", "pwm6", "pwm7"; -+ }; -+ }; -+ -+ spi0_pins: spi0-pins { -+ mux { -+ function = "spi"; -+ groups = "spi0", "spi0_wp_hold"; -+ }; -+ }; -+ -+ mmc1_pins_default: mmc1default { -+ mux { -+ function = "flash"; -+ groups = "emmc_45"; -+ }; -+ -+ conf-cmd-dat { -+ pins = "SPI2_CSB", "SPI2_MISO", "SPI2_MOSI", -+ "SPI2_CLK", "SPI2_HOLD"; -+ input-enable; -+ }; -+ -+ conf-clk { -+ pins = "SPI2_WP"; -+ }; -+ }; -+}; -+ -+&pwm { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pwm_pins>; -+ status = "okay"; -+}; -+ -+&spi0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&spi0_pins>; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ must_tx; -+ enhance_timing; -+ dma_ext; -+ ipm_design; -+ support_quad; -+ tick_dly = <2>; -+ sample_sel = <0>; -+ -+ spi_nand@0 { -+ compatible = "spi-nand"; -+ reg = <0>; -+ spi-max-frequency = <52000000>; -+ }; -+}; -+ -+&mmc0 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&mmc1_pins_default>; -+ max-frequency = <52000000>; -+ bus-width = <4>; -+ cap-sd-highspeed; -+ vmmc-supply = <®_3p3v>; -+ vqmmc-supply = <®_3p3v>; -+ status = "okay"; -+}; ---- /dev/null -+++ b/board/mediatek/mt7988/MAINTAINERS -@@ -0,0 +1,7 @@ -+MT7988 -+M: Sam Shih -+S: Maintained -+F: board/mediatek/mt7988 -+F: include/configs/mt7988.h -+F: configs/mt7988_rfb_defconfig -+F: configs/mt7988_sd_rfb_defconfig ---- /dev/null -+++ b/board/mediatek/mt7988/Makefile -@@ -0,0 +1,3 @@ -+# SPDX-License-Identifier: GPL-2.0 -+ -+obj-y += mt7988_rfb.o ---- /dev/null -+++ b/board/mediatek/mt7988/mt7988_rfb.c -@@ -0,0 +1,10 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (C) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+int board_init(void) -+{ -+ return 0; -+} ---- /dev/null -+++ b/configs/mt7988_rfb_defconfig -@@ -0,0 +1,83 @@ -+CONFIG_ARM=y -+CONFIG_SYS_HAS_NONCACHED_MEMORY=y -+CONFIG_POSITION_INDEPENDENT=y -+CONFIG_ARCH_MEDIATEK=y -+CONFIG_TEXT_BASE=0x41e00000 -+CONFIG_SYS_MALLOC_F_LEN=0x4000 -+CONFIG_NR_DRAM_BANKS=1 -+CONFIG_DEFAULT_DEVICE_TREE="mt7988-rfb" -+CONFIG_SYS_PROMPT="MT7988> " -+CONFIG_TARGET_MT7988=y -+CONFIG_DEBUG_UART_BASE=0x11000000 -+CONFIG_DEBUG_UART_CLOCK=40000000 -+CONFIG_SYS_LOAD_ADDR=0x50000000 -+CONFIG_DEBUG_UART=y -+# CONFIG_AUTOBOOT is not set -+CONFIG_DEFAULT_FDT_FILE="mt7988-rfb" -+CONFIG_LOGLEVEL=7 -+CONFIG_LOG=y -+CONFIG_SYS_CBSIZE=512 -+CONFIG_SYS_PBSIZE=1049 -+# CONFIG_BOOTM_NETBSD is not set -+# CONFIG_BOOTM_PLAN9 is not set -+# CONFIG_BOOTM_RTEMS is not set -+# CONFIG_BOOTM_VXWORKS is not set -+# CONFIG_CMD_ELF is not set -+CONFIG_CMD_CLK=y -+CONFIG_CMD_DM=y -+CONFIG_CMD_GPIO=y -+CONFIG_CMD_PWM=y -+CONFIG_CMD_MMC=y -+CONFIG_CMD_MTD=y -+CONFIG_CMD_PING=y -+CONFIG_CMD_SMC=y -+CONFIG_DOS_PARTITION=y -+CONFIG_EFI_PARTITION=y -+CONFIG_PARTITION_TYPE_GUID=y -+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y -+CONFIG_NET_RANDOM_ETHADDR=y -+CONFIG_USE_IPADDR=y -+CONFIG_IPADDR="192.168.1.1" -+CONFIG_USE_NETMASK=y -+CONFIG_NETMASK="255.255.255.0" -+CONFIG_USE_SERVERIP=y -+CONFIG_SERVERIP="192.168.1.2" -+CONFIG_PROT_TCP=y -+CONFIG_REGMAP=y -+CONFIG_SYSCON=y -+CONFIG_CLK=y -+CONFIG_MMC_HS200_SUPPORT=y -+CONFIG_MMC_MTK=y -+CONFIG_MTD=y -+CONFIG_DM_MTD=y -+CONFIG_MTD_SPI_NAND=y -+CONFIG_DM_SPI_FLASH=y -+CONFIG_SPI_FLASH_SFDP_SUPPORT=y -+CONFIG_SPI_FLASH_EON=y -+CONFIG_SPI_FLASH_GIGADEVICE=y -+CONFIG_SPI_FLASH_ISSI=y -+CONFIG_SPI_FLASH_MACRONIX=y -+CONFIG_SPI_FLASH_SPANSION=y -+CONFIG_SPI_FLASH_STMICRO=y -+CONFIG_SPI_FLASH_WINBOND=y -+CONFIG_SPI_FLASH_XMC=y -+CONFIG_SPI_FLASH_XTX=y -+CONFIG_SPI_FLASH_MTD=y -+CONFIG_PHY_FIXED=y -+CONFIG_MEDIATEK_ETH=y -+CONFIG_PINCTRL=y -+CONFIG_PINCONF=y -+CONFIG_PINCTRL_MT7988=y -+CONFIG_POWER_DOMAIN=y -+CONFIG_MTK_POWER_DOMAIN=y -+CONFIG_DM_PWM=y -+CONFIG_PWM_MTK=y -+CONFIG_RAM=y -+CONFIG_DM_SERIAL=y -+CONFIG_MTK_SERIAL=y -+CONFIG_SPI=y -+CONFIG_DM_SPI=y -+CONFIG_MTK_SPIM=y -+CONFIG_LZO=y -+CONFIG_HEXDUMP=y -+# CONFIG_EFI_LOADER is not set ---- /dev/null -+++ b/configs/mt7988_sd_rfb_defconfig -@@ -0,0 +1,71 @@ -+CONFIG_ARM=y -+CONFIG_SYS_HAS_NONCACHED_MEMORY=y -+CONFIG_POSITION_INDEPENDENT=y -+CONFIG_ARCH_MEDIATEK=y -+CONFIG_TEXT_BASE=0x41e00000 -+CONFIG_SYS_MALLOC_F_LEN=0x4000 -+CONFIG_NR_DRAM_BANKS=1 -+CONFIG_DEFAULT_DEVICE_TREE="mt7988-sd-rfb" -+CONFIG_SYS_PROMPT="MT7988> " -+CONFIG_TARGET_MT7988=y -+CONFIG_DEBUG_UART_BASE=0x11000000 -+CONFIG_DEBUG_UART_CLOCK=40000000 -+CONFIG_SYS_LOAD_ADDR=0x50000000 -+CONFIG_DEBUG_UART=y -+# CONFIG_AUTOBOOT is not set -+CONFIG_DEFAULT_FDT_FILE="mt7988-sd-rfb" -+CONFIG_LOGLEVEL=7 -+CONFIG_LOG=y -+CONFIG_SYS_CBSIZE=512 -+CONFIG_SYS_PBSIZE=1049 -+# CONFIG_BOOTM_NETBSD is not set -+# CONFIG_BOOTM_PLAN9 is not set -+# CONFIG_BOOTM_RTEMS is not set -+# CONFIG_BOOTM_VXWORKS is not set -+# CONFIG_CMD_ELF is not set -+CONFIG_CMD_CLK=y -+CONFIG_CMD_DM=y -+CONFIG_CMD_GPIO=y -+CONFIG_CMD_PWM=y -+CONFIG_CMD_MMC=y -+CONFIG_CMD_MTD=y -+CONFIG_CMD_PING=y -+CONFIG_CMD_SMC=y -+CONFIG_DOS_PARTITION=y -+CONFIG_EFI_PARTITION=y -+CONFIG_PARTITION_TYPE_GUID=y -+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y -+CONFIG_NET_RANDOM_ETHADDR=y -+CONFIG_USE_IPADDR=y -+CONFIG_IPADDR="192.168.1.1" -+CONFIG_USE_NETMASK=y -+CONFIG_NETMASK="255.255.255.0" -+CONFIG_USE_SERVERIP=y -+CONFIG_SERVERIP="192.168.1.2" -+CONFIG_PROT_TCP=y -+CONFIG_REGMAP=y -+CONFIG_SYSCON=y -+CONFIG_CLK=y -+CONFIG_MMC_HS200_SUPPORT=y -+CONFIG_MMC_MTK=y -+CONFIG_MTD=y -+CONFIG_DM_MTD=y -+CONFIG_MTD_SPI_NAND=y -+CONFIG_PHY_FIXED=y -+CONFIG_MEDIATEK_ETH=y -+CONFIG_PINCTRL=y -+CONFIG_PINCONF=y -+CONFIG_PINCTRL_MT7988=y -+CONFIG_POWER_DOMAIN=y -+CONFIG_MTK_POWER_DOMAIN=y -+CONFIG_DM_PWM=y -+CONFIG_PWM_MTK=y -+CONFIG_RAM=y -+CONFIG_DM_SERIAL=y -+CONFIG_MTK_SERIAL=y -+CONFIG_SPI=y -+CONFIG_DM_SPI=y -+CONFIG_MTK_SPIM=y -+CONFIG_LZO=y -+CONFIG_HEXDUMP=y -+# CONFIG_EFI_LOADER is not set ---- /dev/null -+++ b/include/configs/mt7988.h -@@ -0,0 +1,14 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+/* -+ * Configuration for MediaTek MT7988 SoC -+ * -+ * Copyright (C) 2022 MediaTek Inc. -+ * Author: Sam Shih -+ */ -+ -+#ifndef __MT7988_H -+#define __MT7988_H -+ -+#define CFG_MAX_MEM_MAPPED 0xC0000000 -+ -+#endif diff --git a/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch b/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch deleted file mode 100644 index 3cfc6849563092..00000000000000 --- a/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 4bd66fd5b69eda41b4320fd6f8db50a7b7fa7bf7 Mon Sep 17 00:00:00 2001 -Message-ID: <4bd66fd5b69eda41b4320fd6f8db50a7b7fa7bf7.1690828424.git.daniel@makrotopia.org> -From: Daniel Golle -Date: Mon, 31 Jul 2023 19:25:04 +0100 -Subject: [PATCH] ram: mediatek: include for SZ_* macros -To: Ryder Lee , - Weijie Gao , - Chunfeng Yun , - GSS_MTK_Uboot_upstream , - u-boot@lists.denx.de - -Something between U-Boot 2023.04 and 2023.07.02 resulted in no longer -implicitely including in the DDR3 RAM driver for the -MT7929 SoC. The result is a build failure: -drivers/ram/mediatek/ddr3-mt7629.c: In function 'mtk_ddr3_get_info': -drivers/ram/mediatek/ddr3-mt7629.c:734:30: error: 'SZ_128M' undeclared (first use in this function) - 734 | info->size = SZ_128M; - | ^~~~~~~ -drivers/ram/mediatek/ddr3-mt7629.c:734:30: note: each undeclared identifier is reported only once for each function it appears in -drivers/ram/mediatek/ddr3-mt7629.c:737:30: error: 'SZ_256M' undeclared (first use in this function) - 737 | info->size = SZ_256M; - | ^~~~~~~ -drivers/ram/mediatek/ddr3-mt7629.c:740:30: error: 'SZ_512M' undeclared (first use in this function) - 740 | info->size = SZ_512M; - | ^~~~~~~ -drivers/ram/mediatek/ddr3-mt7629.c:743:30: error: 'SZ_1G' undeclared (first use in this function) - 743 | info->size = SZ_1G; - | ^~~~~ - -Include so SZ_* is defined. - -Reported-by: Tianling Shen -Signed-off-by: Daniel Golle ---- - drivers/ram/mediatek/ddr3-mt7629.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/ram/mediatek/ddr3-mt7629.c -+++ b/drivers/ram/mediatek/ddr3-mt7629.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - - /* EMI */ - #define EMI_CONA 0x000 diff --git a/package/boot/uboot-mediatek/patches/103-mt7988-enable-pstore.patch b/package/boot/uboot-mediatek/patches/103-mt7988-enable-pstore.patch index a34dcddd71bc79..747aa2e5daccc6 100644 --- a/package/boot/uboot-mediatek/patches/103-mt7988-enable-pstore.patch +++ b/package/boot/uboot-mediatek/patches/103-mt7988-enable-pstore.patch @@ -1,6 +1,6 @@ --- a/arch/arm/dts/mt7988.dtsi +++ b/arch/arm/dts/mt7988.dtsi -@@ -61,6 +61,30 @@ +@@ -62,6 +62,30 @@ #clock-cells = <0>; }; diff --git a/package/boot/uboot-mediatek/patches/104-configs-set-CONFIG_LMB_MAX_REGIONS-64-for-MT7988-boards.patch b/package/boot/uboot-mediatek/patches/104-configs-set-CONFIG_LMB_MAX_REGIONS-64-for-MT7988-boards.patch deleted file mode 100644 index f0475188524c84..00000000000000 --- a/package/boot/uboot-mediatek/patches/104-configs-set-CONFIG_LMB_MAX_REGIONS-64-for-MT7988-boards.patch +++ /dev/null @@ -1,69 +0,0 @@ -From patchwork Mon Aug 21 19:38:23 2023 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Daniel Golle -X-Patchwork-Id: 1823742 -X-Patchwork-Delegate: trini@ti.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Date: Mon, 21 Aug 2023 20:38:23 +0100 -From: Daniel Golle -To: Sam Shih , Weijie Gao , - Lorenzo Bianconi , u-boot@lists.denx.de -Subject: [PATCH] configs: set CONFIG_LMB_MAX_REGIONS=64 for MT7988 boards -Message-ID: - <568a8030acf9056266b5c96055cea54f810496c9.1692646620.git.daniel@makrotopia.org> -MIME-Version: 1.0 -Content-Disposition: inline -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" - -Similar to MT7981 and MT7986 also MT7988 can have a high number of -reserved-memory regions used by the various hardware offloading -subsystems. - -Raise CONFIG_LMB_MAX_REGIONS to 64 to avoid errors when trying to boot -Linux with more then 6 reserved regions: - -ERROR: reserving fdt memory region failed (addr=4f700000 size=240000 flags=4) -ERROR: reserving fdt memory region failed (addr=15194000 size=1000 flags=4) -ERROR: reserving fdt memory region failed (addr=15294000 size=1000 flags=4) -ERROR: reserving fdt memory region failed (addr=15394000 size=1000 flags=4) -ERROR: Failed to allocate 0xb161 bytes below 0x80000000. -device tree - allocation error - -Fixes: bc4adc97cfb ("board: mediatek: add MT7988 reference boards") -Reported-by: Lorenzo Bianconi -Signed-off-by: Daniel Golle ---- - configs/mt7988_rfb_defconfig | 1 + - configs/mt7988_sd_rfb_defconfig | 1 + - 2 files changed, 2 insertions(+) - ---- a/configs/mt7988_rfb_defconfig -+++ b/configs/mt7988_rfb_defconfig -@@ -81,3 +81,4 @@ CONFIG_MTK_SPIM=y - CONFIG_LZO=y - CONFIG_HEXDUMP=y - # CONFIG_EFI_LOADER is not set -+CONFIG_LMB_MAX_REGIONS=64 ---- a/configs/mt7988_sd_rfb_defconfig -+++ b/configs/mt7988_sd_rfb_defconfig -@@ -69,3 +69,4 @@ CONFIG_MTK_SPIM=y - CONFIG_LZO=y - CONFIG_HEXDUMP=y - # CONFIG_EFI_LOADER is not set -+CONFIG_LMB_MAX_REGIONS=64 diff --git a/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch b/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch index c7dcf9a1ba7d98..da1d985688b981 100644 --- a/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch +++ b/package/boot/uboot-mediatek/patches/105-configs-add-usefull-stuff-to-mt7988-rfb.patch @@ -1,8 +1,8 @@ --- a/configs/mt7988_sd_rfb_defconfig +++ b/configs/mt7988_sd_rfb_defconfig -@@ -12,6 +12,24 @@ CONFIG_DEBUG_UART_BASE=0x11000000 +@@ -11,6 +11,24 @@ CONFIG_DEBUG_UART_BASE=0x11000000 CONFIG_DEBUG_UART_CLOCK=40000000 - CONFIG_SYS_LOAD_ADDR=0x50000000 + CONFIG_SYS_LOAD_ADDR=0x46000000 CONFIG_DEBUG_UART=y +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SMBIOS_PRODUCT_NAME="" @@ -157,9 +157,9 @@ CONFIG_MTD=y --- a/configs/mt7988_rfb_defconfig +++ b/configs/mt7988_rfb_defconfig -@@ -12,6 +12,24 @@ CONFIG_DEBUG_UART_BASE=0x11000000 +@@ -11,6 +11,24 @@ CONFIG_DEBUG_UART_BASE=0x11000000 CONFIG_DEBUG_UART_CLOCK=40000000 - CONFIG_SYS_LOAD_ADDR=0x50000000 + CONFIG_SYS_LOAD_ADDR=0x46000000 CONFIG_DEBUG_UART=y +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SMBIOS_PRODUCT_NAME="" diff --git a/package/boot/uboot-mediatek/patches/107-configs-add-useful-options-to-mt7981-rfb.patch b/package/boot/uboot-mediatek/patches/107-configs-add-useful-options-to-mt7981-rfb.patch index f5234ea0859d23..bd4c6b55f03c7d 100644 --- a/package/boot/uboot-mediatek/patches/107-configs-add-useful-options-to-mt7981-rfb.patch +++ b/package/boot/uboot-mediatek/patches/107-configs-add-useful-options-to-mt7981-rfb.patch @@ -1,6 +1,6 @@ --- a/configs/mt7981_emmc_rfb_defconfig +++ b/configs/mt7981_emmc_rfb_defconfig -@@ -14,7 +14,22 @@ CONFIG_DEBUG_UART_BASE=0x11002000 +@@ -13,7 +13,22 @@ CONFIG_DEBUG_UART_BASE=0x11002000 CONFIG_DEBUG_UART_CLOCK=40000000 CONFIG_SYS_LOAD_ADDR=0x46000000 CONFIG_DEBUG_UART=y @@ -87,7 +87,7 @@ CONFIG_CLK=y --- a/configs/mt7981_rfb_defconfig +++ b/configs/mt7981_rfb_defconfig -@@ -12,7 +12,23 @@ CONFIG_DEBUG_UART_BASE=0x11002000 +@@ -11,7 +11,23 @@ CONFIG_DEBUG_UART_BASE=0x11002000 CONFIG_DEBUG_UART_CLOCK=40000000 CONFIG_SYS_LOAD_ADDR=0x46000000 CONFIG_DEBUG_UART=y @@ -191,7 +191,7 @@ CONFIG_MTD_SPI_NAND=y --- a/configs/mt7981_sd_rfb_defconfig +++ b/configs/mt7981_sd_rfb_defconfig -@@ -14,7 +14,22 @@ CONFIG_DEBUG_UART_BASE=0x11002000 +@@ -13,7 +13,22 @@ CONFIG_DEBUG_UART_BASE=0x11002000 CONFIG_DEBUG_UART_CLOCK=40000000 CONFIG_SYS_LOAD_ADDR=0x46000000 CONFIG_DEBUG_UART=y diff --git a/package/boot/uboot-mediatek/patches/110-no-kwbimage.patch b/package/boot/uboot-mediatek/patches/110-no-kwbimage.patch index 2d61d6f4a7ecb3..3bf033f8143243 100644 --- a/package/boot/uboot-mediatek/patches/110-no-kwbimage.patch +++ b/package/boot/uboot-mediatek/patches/110-no-kwbimage.patch @@ -5,6 +5,6 @@ imx8image.o \ imx8mimage.o \ - kwbimage.o \ - lib/md5.o \ + generated/lib/md5.o \ lpc32xximage.o \ mxsimage.o \ diff --git a/package/boot/uboot-mediatek/patches/120-use-xz-instead-of-lzma.patch b/package/boot/uboot-mediatek/patches/120-use-xz-instead-of-lzma.patch index 411f99467b74d0..9a9224963d49ea 100644 --- a/package/boot/uboot-mediatek/patches/120-use-xz-instead-of-lzma.patch +++ b/package/boot/uboot-mediatek/patches/120-use-xz-instead-of-lzma.patch @@ -1,6 +1,6 @@ --- a/Makefile +++ b/Makefile -@@ -1070,7 +1070,7 @@ quiet_cmd_pad_cat = CAT $@ +@@ -1083,7 +1083,7 @@ quiet_cmd_pad_cat = CAT $@ cmd_pad_cat = $(cmd_objcopy) && $(append) || { rm -f $@; false; } quiet_cmd_lzma = LZMA $@ diff --git a/package/boot/uboot-mediatek/patches/130-fix-mkimage-host-build.patch b/package/boot/uboot-mediatek/patches/130-fix-mkimage-host-build.patch index cd65c1321fc320..86a424e8b769d3 100644 --- a/package/boot/uboot-mediatek/patches/130-fix-mkimage-host-build.patch +++ b/package/boot/uboot-mediatek/patches/130-fix-mkimage-host-build.patch @@ -1,6 +1,6 @@ --- a/tools/image-host.c +++ b/tools/image-host.c -@@ -1125,6 +1125,7 @@ static int fit_config_add_verification_d +@@ -1137,6 +1137,7 @@ static int fit_config_add_verification_d * 2) get public key (X509_get_pubkey) * 3) provide der format (d2i_RSAPublicKey) */ @@ -8,7 +8,7 @@ static int read_pub_key(const char *keydir, const void *name, unsigned char **pubkey, int *pubkey_len) { -@@ -1178,6 +1179,13 @@ err_cert: +@@ -1190,6 +1191,13 @@ err_cert: fclose(f); return ret; } diff --git a/package/boot/uboot-mediatek/patches/131-spi-mtk_spim-prevent-global-pll-clock-override.patch b/package/boot/uboot-mediatek/patches/131-spi-mtk_spim-prevent-global-pll-clock-override.patch deleted file mode 100644 index c4e0fff921f453..00000000000000 --- a/package/boot/uboot-mediatek/patches/131-spi-mtk_spim-prevent-global-pll-clock-override.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 41f225dae30ea6ddcff10f120a9e732f994d3a07 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Nicol=C3=B2=20Veronese?= -Date: Tue, 3 Oct 2023 23:46:52 +0200 -Subject: [PATCH] spi: mtk_spim: prevent global pll clock override -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -With commit 793e6230118032a099ec42a1ea67f434721edcc0 - a new system to calculate the SPI clocks has been added. - -Unfortunately, the do_div macro overrides the global - priv->pll_clk_rate field. This will cause to have a reduced - clock rate on each subsequent SPI call. - -Signed-off-by: Valerio 'ftp21' Mancini -Signed-off-by: Nicolò Veronese ---- - drivers/spi/mtk_spim.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - ---- a/drivers/spi/mtk_spim.c -+++ b/drivers/spi/mtk_spim.c -@@ -409,7 +409,7 @@ static int mtk_spim_transfer_wait(struct - { - struct udevice *bus = dev_get_parent(slave->dev); - struct mtk_spim_priv *priv = dev_get_priv(bus); -- u32 sck_l, sck_h, clk_count, reg; -+ u32 pll_clk, sck_l, sck_h, clk_count, reg; - ulong us = 1; - int ret = 0; - -@@ -418,11 +418,12 @@ static int mtk_spim_transfer_wait(struct - else - clk_count = op->data.nbytes; - -+ pll_clk = priv->pll_clk_rate; - sck_l = readl(priv->base + SPI_CFG2_REG) >> SPI_CFG2_SCK_LOW_OFFSET; - sck_h = readl(priv->base + SPI_CFG2_REG) & SPI_CFG2_SCK_HIGH_MASK; -- do_div(priv->pll_clk_rate, sck_l + sck_h + 2); -+ do_div(pll_clk, sck_l + sck_h + 2); - -- us = CLK_TO_US(priv->pll_clk_rate, clk_count * 8); -+ us = CLK_TO_US(pll_clk, clk_count * 8); - us += 1000 * 1000; /* 1s tolerance */ - - if (us > UINT_MAX) diff --git a/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch b/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch new file mode 100644 index 00000000000000..f8e86599527825 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/160-net-phy-add-support-for-Airoha-ethernet-PHY-driver.patch @@ -0,0 +1,1929 @@ +From 70157a6148ad47734f1dc646b4157ca83cc5df9f Mon Sep 17 00:00:00 2001 +From: Weijie Gao +Date: Thu, 13 Jul 2023 16:34:48 +0800 +Subject: [PATCH] net: phy: add support for Airoha ethernet PHY driver + +This patch adds support for Airoha ethernet PHY driver. + +If GMAC2 of your board connects to Airoha EN8801S, please change the eth +node as follow: + +ð { + status = "okay"; + mediatek,gmac-id = <1>; + mediatek,sgmiisys = <&sgmiisys1>; + phy-mode = "sgmii"; + phy-handle = <&phy5>; + + phy5: eth-phy@5 { + reg = <24>; + }; +}; + +If GMAC2 of your board connects to Airoha EN8811H, please change the eth +node as follow: + +ð { + status = "okay"; + mediatek,gmac-id = <1>; + mediatek,sgmiisys = <&sgmiisys1>; + phy-mode = "2500base-x"; + phy-handle = <&phy5>; + + fixed-link { + speed = <2500>; + full-duplex; + }; + + phy5: eth-phy@5 { + reg = <15>; + }; +}; + +Signed-off-by: Weijie Gao +--- + .../drivers/net/phy/Kconfig | 15 + + .../drivers/net/phy/Makefile | 2 + + .../drivers/net/phy/air_en8801s.c | 633 ++ + .../drivers/net/phy/air_en8801s.h | 267 + + .../drivers/net/phy/air_en8811h.c | 649 ++ + .../drivers/net/phy/air_en8811h.h | 160 + + .../drivers/net/phy/air_en8811h_fw.h | 9227 +++++++++++++++++ + 7 files changed, 10953 insertions(+) + create mode 100644 drivers/net/phy/air_en8801s.c + create mode 100644 drivers/net/phy/air_en8801s.h + create mode 100644 drivers/net/phy/air_en8811h.c + create mode 100644 drivers/net/phy/air_en8811h.h + create mode 100644 drivers/net/phy/air_en8811h_fw.h + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -77,6 +77,37 @@ config PHY_ADIN + help + Add support for configuring RGMII on Analog Devices ADIN PHYs. + ++menuconfig PHY_AIROHA ++ bool "Airoha Ethernet PHYs support" ++ ++config PHY_AIROHA_EN8801S ++ bool "Airoha Ethernet EN8801S support" ++ depends on PHY_AIROHA ++ help ++ AIROHA EN8801S supported. ++ ++config PHY_AIROHA_EN8811H ++ bool "Airoha Ethernet EN8811H support" ++ depends on PHY_AIROHA ++ help ++ AIROHA EN8811H supported. ++ ++choice ++ prompt "Location of the Airoha PHY firmware" ++ default PHY_AIROHA_FW_IN_UBI ++ depends on PHY_AIROHA_EN8811H ++ ++config PHY_AIROHA_FW_IN_MMC ++ bool "Airoha firmware in MMC boot1 partition" ++ ++config PHY_AIROHA_FW_IN_UBI ++ bool "Airoha firmware in UBI volume en8811h-fw on NAND flash" ++ ++config PHY_AIROHA_FW_IN_MTD ++ bool "Airoha firmware in MTD partition on raw flash" ++ ++endchoice ++ + menuconfig PHY_AQUANTIA + bool "Aquantia Ethernet PHYs support" + select PHY_GIGE +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -11,6 +11,8 @@ obj-$(CONFIG_MV88E6352_SWITCH) += mv88e6 + obj-$(CONFIG_PHYLIB) += phy.o + obj-$(CONFIG_PHYLIB_10G) += generic_10g.o + obj-$(CONFIG_PHY_ADIN) += adin.o ++obj-$(CONFIG_PHY_AIROHA_EN8801S) += air_en8801s.o ++obj-$(CONFIG_PHY_AIROHA_EN8811H) += air_en8811h.o + obj-$(CONFIG_PHY_AQUANTIA) += aquantia.o + obj-$(CONFIG_PHY_ATHEROS) += atheros.o + obj-$(CONFIG_PHY_BROADCOM) += broadcom.o +--- /dev/null ++++ b/drivers/net/phy/air_en8801s.c +@@ -0,0 +1,633 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/************************************************* ++ * FILE NAME: air_en8801s.c ++ * PURPOSE: ++ * EN8801S PHY Driver for Uboot ++ * NOTES: ++ * ++ * Copyright (C) 2023 Airoha Technology Corp. ++ *************************************************/ ++ ++/* INCLUDE FILE DECLARATIONS ++ */ ++#include ++#include ++#include ++#include ++#include "air_en8801s.h" ++ ++#if AIR_UBOOT_REVISION > 0x202004 ++#include ++#endif ++ ++static struct phy_device *s_phydev = 0; ++/****************************************************** ++ * The following led_cfg example is for reference only. ++ * LED5 1000M/LINK/ACT (GPIO5) <-> BASE_T_LED0, ++ * LED6 10/100M/LINK/ACT (GPIO9) <-> BASE_T_LED1, ++ * LED4 100M/LINK/ACT (GPIO8) <-> BASE_T_LED2, ++ ******************************************************/ ++/* User-defined.B */ ++#define AIR_LED_SUPPORT ++#ifdef AIR_LED_SUPPORT ++static const AIR_BASE_T_LED_CFG_T led_cfg[4] = ++{ ++ /* ++ * LED Enable, GPIO, LED Polarity, LED ON, LED Blink ++ */ ++ {LED_ENABLE, 5, AIR_ACTIVE_LOW, BASE_T_LED0_ON_CFG, BASE_T_LED0_BLK_CFG}, /* BASE-T LED0 */ ++ {LED_ENABLE, 9, AIR_ACTIVE_LOW, BASE_T_LED1_ON_CFG, BASE_T_LED1_BLK_CFG}, /* BASE-T LED1 */ ++ {LED_ENABLE, 8, AIR_ACTIVE_LOW, BASE_T_LED2_ON_CFG, BASE_T_LED2_BLK_CFG}, /* BASE-T LED2 */ ++ {LED_DISABLE, 1, AIR_ACTIVE_LOW, BASE_T_LED3_ON_CFG, BASE_T_LED3_BLK_CFG} /* BASE-T LED3 */ ++}; ++static const u16 led_dur = UNIT_LED_BLINK_DURATION << AIR_LED_BLK_DUR_64M; ++#endif ++/* User-defined.E */ ++/************************************************************************ ++ * F U N C T I O N S ++ ************************************************************************/ ++/* Airoha MII read function */ ++static int airoha_cl22_read(struct mii_dev *bus, int phy_addr, int phy_register) ++{ ++ int read_data = bus->read(bus, phy_addr, MDIO_DEVAD_NONE, phy_register); ++ ++ if (read_data < 0) ++ return -EIO; ++ return read_data; ++} ++ ++/* Airoha MII write function */ ++static int airoha_cl22_write(struct mii_dev *bus, int phy_addr, int phy_register, int write_data) ++{ ++ int ret = bus->write(bus, phy_addr, MDIO_DEVAD_NONE, phy_register, write_data); ++ ++ return ret; ++} ++ ++static int airoha_cl45_write(struct phy_device *phydev, int devad, int reg, int val) ++{ ++ int ret = 0; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, devad); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, reg); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, MMD_OP_MODE_DATA | devad); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, val); ++ AIR_RTN_ERR(ret); ++ return ret; ++} ++ ++static int airoha_cl45_read(struct phy_device *phydev, int devad, int reg) ++{ ++ int read_data, ret; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, devad); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, reg); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, MMD_OP_MODE_DATA | devad); ++ AIR_RTN_ERR(ret); ++ read_data = phy_read(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG); ++ if (read_data < 0) ++ return -EIO; ++ return read_data; ++} ++ ++/* EN8801 PBUS write function */ ++int airoha_pbus_write(struct mii_dev *bus, int pbus_addr, int pbus_reg, unsigned long pbus_data) ++{ ++ int ret = 0; ++ ++ ret = airoha_cl22_write(bus, pbus_addr, 0x1F, (pbus_reg >> 6)); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl22_write(bus, pbus_addr, ((pbus_reg >> 2) & 0xf), (pbus_data & 0xFFFF)); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl22_write(bus, pbus_addr, 0x10, (pbus_data >> 16)); ++ AIR_RTN_ERR(ret); ++ return ret; ++} ++ ++/* EN8801 PBUS read function */ ++unsigned long airoha_pbus_read(struct mii_dev *bus, int pbus_addr, int pbus_reg) ++{ ++ unsigned long pbus_data; ++ unsigned int pbus_data_low, pbus_data_high; ++ ++ airoha_cl22_write(bus, pbus_addr, 0x1F, (pbus_reg >> 6)); ++ pbus_data_low = airoha_cl22_read(bus, pbus_addr, ((pbus_reg >> 2) & 0xf)); ++ pbus_data_high = airoha_cl22_read(bus, pbus_addr, 0x10); ++ pbus_data = (pbus_data_high << 16) + pbus_data_low; ++ return pbus_data; ++} ++ ++/* Airoha Token Ring Write function */ ++static int airoha_tr_reg_write(struct phy_device *phydev, unsigned long tr_address, unsigned long tr_data) ++{ ++ int ret; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, 0x52b5); /* page select */ ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x11, (int)(tr_data & 0xffff)); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x12, (int)(tr_data >> 16)); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x10, (int)(tr_address | TrReg_WR)); ++ AIR_RTN_ERR(ret); ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, 0x0); /* page resetore */ ++ AIR_RTN_ERR(ret); ++ return ret; ++} ++ ++int airoha_phy_process(void) ++{ ++ int ret = 0, pbus_addr = EN8801S_PBUS_PHY_ID; ++ unsigned long pbus_data; ++ struct mii_dev *mbus; ++ ++ mbus = s_phydev->bus; ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x19e0); ++ pbus_data |= BIT(0); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x19e0, pbus_data); ++ if(ret) ++ printf("error: airoha_pbus_write fail ret: %d\n", ret); ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x19e0); ++ pbus_data &= ~BIT(0); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x19e0, pbus_data); ++ if(ret) ++ printf("error: airoha_pbus_write fail ret: %d\n", ret); ++ ++ if(ret) ++ printf("error: FCM regs reset fail, ret: %d\n", ret); ++ else ++ debug("FCM regs reset successful\n"); ++ return ret; ++} ++ ++#ifdef AIR_LED_SUPPORT ++static int airoha_led_set_usr_def(struct phy_device *phydev, u8 entity, int polar, ++ u16 on_evt, u16 blk_evt) ++{ ++ int ret = 0; ++ ++ if (AIR_ACTIVE_HIGH == polar) { ++ on_evt |= LED_ON_POL; ++ } else { ++ on_evt &= ~LED_ON_POL; ++ } ++ ret = airoha_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), on_evt | LED_ON_EN); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1f, LED_BLK_CTRL(entity), blk_evt); ++ AIR_RTN_ERR(ret); ++ return 0; ++} ++ ++static int airoha_led_set_mode(struct phy_device *phydev, u8 mode) ++{ ++ u16 cl45_data; ++ int err = 0; ++ ++ cl45_data = airoha_cl45_read(phydev, 0x1f, LED_BCR); ++ switch (mode) { ++ case AIR_LED_MODE_DISABLE: ++ cl45_data &= ~LED_BCR_EXT_CTRL; ++ cl45_data &= ~LED_BCR_MODE_MASK; ++ cl45_data |= LED_BCR_MODE_DISABLE; ++ break; ++ case AIR_LED_MODE_USER_DEFINE: ++ cl45_data |= LED_BCR_EXT_CTRL; ++ cl45_data |= LED_BCR_CLK_EN; ++ break; ++ default: ++ printf("LED mode%d is not supported!\n", mode); ++ return -EINVAL; ++ } ++ err = airoha_cl45_write(phydev, 0x1f, LED_BCR, cl45_data); ++ AIR_RTN_ERR(err); ++ return 0; ++} ++ ++static int airoha_led_set_state(struct phy_device *phydev, u8 entity, u8 state) ++{ ++ u16 cl45_data; ++ int err; ++ ++ cl45_data = airoha_cl45_read(phydev, 0x1f, LED_ON_CTRL(entity)); ++ if (LED_ENABLE == state) { ++ cl45_data |= LED_ON_EN; ++ } else { ++ cl45_data &= ~LED_ON_EN; ++ } ++ ++ err = airoha_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), cl45_data); ++ AIR_RTN_ERR(err); ++ return 0; ++} ++ ++static int en8801s_led_init(struct phy_device *phydev) ++{ ++ ++ unsigned long led_gpio = 0, reg_value = 0; ++ int ret = 0, led_id; ++ struct mii_dev *mbus = phydev->bus; ++ int gpio_led_rg[3] = {0x1870, 0x1874, 0x1878}; ++ u16 cl45_data = led_dur; ++ ++ ret = airoha_cl45_write(phydev, 0x1f, LED_BLK_DUR, cl45_data); ++ AIR_RTN_ERR(ret); ++ cl45_data >>= 1; ++ ret = airoha_cl45_write(phydev, 0x1f, LED_ON_DUR, cl45_data); ++ AIR_RTN_ERR(ret); ++ ret = airoha_led_set_mode(phydev, AIR_LED_MODE_USER_DEFINE); ++ if (ret != 0) { ++ printf("LED fail to set mode, ret %d !\n", ret); ++ return ret; ++ } ++ for(led_id = 0; led_id < EN8801S_LED_COUNT; led_id++) { ++ reg_value = 0; ++ ret = airoha_led_set_state(phydev, led_id, led_cfg[led_id].en); ++ if (ret != 0) { ++ printf("LED fail to set state, ret %d !\n", ret); ++ return ret; ++ } ++ if (LED_ENABLE == led_cfg[led_id].en) { ++ if ( (led_cfg[led_id].gpio < 0) || led_cfg[led_id].gpio > 9) { ++ printf("GPIO%d is out of range!! GPIO number is 0~9.\n", led_cfg[led_id].gpio); ++ return -EIO; ++ } ++ led_gpio |= BIT(led_cfg[led_id].gpio); ++ reg_value = airoha_pbus_read(mbus, EN8801S_PBUS_PHY_ID, gpio_led_rg[led_cfg[led_id].gpio / 4]); ++ LED_SET_GPIO_SEL(led_cfg[led_id].gpio, led_id, reg_value); ++ debug("[Airoha] gpio%d, reg_value 0x%lx\n", led_cfg[led_id].gpio, reg_value); ++ ret = airoha_pbus_write(mbus, EN8801S_PBUS_PHY_ID, gpio_led_rg[led_cfg[led_id].gpio / 4], reg_value); ++ AIR_RTN_ERR(ret); ++ ret = airoha_led_set_usr_def(phydev, led_id, led_cfg[led_id].pol, led_cfg[led_id].on_cfg, led_cfg[led_id].blk_cfg); ++ if (ret != 0) { ++ printf("LED fail to set usr def, ret %d !\n", ret); ++ return ret; ++ } ++ } ++ } ++ reg_value = (airoha_pbus_read(mbus, EN8801S_PBUS_PHY_ID, 0x1880) & ~led_gpio); ++ ret = airoha_pbus_write(mbus, EN8801S_PBUS_PHY_ID, 0x1880, reg_value); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, EN8801S_PBUS_PHY_ID, 0x186c, led_gpio); ++ AIR_RTN_ERR(ret); ++ ++ printf("LED initialize OK !\n"); ++ return 0; ++} ++#endif /* AIR_LED_SUPPORT */ ++ ++static int en8801s_config(struct phy_device *phydev) ++{ ++ int reg_value = 0, ret = 0; ++ struct mii_dev *mbus = phydev->bus; ++ int retry, pbus_addr = EN8801S_PBUS_DEFAULT_ID; ++ int phy_addr = EN8801S_MDIO_PHY_ID; ++ unsigned long pbus_data = 0; ++ gephy_all_REG_LpiReg1Ch GPHY_RG_LPI_1C; ++ gephy_all_REG_dev1Eh_reg324h GPHY_RG_1E_324; ++ gephy_all_REG_dev1Eh_reg012h GPHY_RG_1E_012; ++ gephy_all_REG_dev1Eh_reg017h GPHY_RG_1E_017; ++ ++ s_phydev = phydev; ++ retry = MAX_OUI_CHECK; ++ while (1) { ++ /* PHY OUI */ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, EN8801S_RG_ETHER_PHY_OUI); ++ if (EN8801S_PBUS_OUI == pbus_data) { ++ printf("PBUS addr 0x%x: Start initialized.\n", pbus_addr); ++ ret = airoha_pbus_write(mbus, pbus_addr, EN8801S_RG_BUCK_CTL, 0x03); ++ AIR_RTN_ERR(ret); ++ break; ++ } else ++ pbus_addr = EN8801S_PBUS_PHY_ID; ++ ++ if (0 == --retry) { ++ printf("EN8801S Probe fail !\n"); ++ return 0; ++ } ++ } ++ ++ /* SMI ADDR */ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, EN8801S_RG_SMI_ADDR); ++ pbus_data = (pbus_data & 0xffff0000) | (unsigned long)(pbus_addr << 8) | (unsigned long)(EN8801S_MDIO_DEFAULT_ID); ++ ret = airoha_pbus_write(mbus, pbus_addr, EN8801S_RG_SMI_ADDR, pbus_data); ++ AIR_RTN_ERR(ret); ++ mdelay(10); ++ ++ pbus_data = (airoha_pbus_read(mbus, pbus_addr, EN8801S_RG_LTR_CTL) & (~0x3)) | BIT(2) ; ++ ret = airoha_pbus_write(mbus, pbus_addr, EN8801S_RG_LTR_CTL, pbus_data); ++ AIR_RTN_ERR(ret); ++ mdelay(500); ++ pbus_data = (pbus_data & ~BIT(2)) | EN8801S_RX_POLARITY_NORMAL | EN8801S_TX_POLARITY_NORMAL; ++ ret = airoha_pbus_write(mbus, pbus_addr, EN8801S_RG_LTR_CTL, pbus_data); ++ AIR_RTN_ERR(ret); ++ mdelay(500); ++ /* SMI ADDR */ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, EN8801S_RG_SMI_ADDR); ++ pbus_data = (pbus_data & 0xffff0000) | (unsigned long)(EN8801S_PBUS_PHY_ID << 8) | (unsigned long)(EN8801S_MDIO_PHY_ID); ++ ret = airoha_pbus_write(mbus, pbus_addr, EN8801S_RG_SMI_ADDR, pbus_data); ++ pbus_addr = EN8801S_PBUS_PHY_ID; ++ AIR_RTN_ERR(ret); ++ mdelay(10); ++ ++ /* Optimze 10M IoT */ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1690); ++ pbus_data |= (1 << 31); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1690, pbus_data); ++ AIR_RTN_ERR(ret); ++ /* set SGMII Base Page */ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c000c00); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x10, 0xD801); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0, 0x9140); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0A14, 0x0003); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c000c00); ++ AIR_RTN_ERR(ret); ++ /* Set FCM control */ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1404, 0x004b); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x140c, 0x0007); ++ AIR_RTN_ERR(ret); ++ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x142c, 0x05050505); ++ AIR_RTN_ERR(ret); ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1440); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1440, pbus_data & ~BIT(11)); ++ AIR_RTN_ERR(ret); ++ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1408); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1408, pbus_data | BIT(5)); ++ AIR_RTN_ERR(ret); ++ ++ /* Set GPHY Perfomance*/ ++ /* Token Ring */ ++ ret = airoha_tr_reg_write(phydev, RgAddr_R1000DEC_15h, 0x0055A0); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_R1000DEC_17h, 0x07FF3F); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_PMA_00h, 0x00001E); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_PMA_01h, 0x6FB90A); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_PMA_17h, 0x060671); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_PMA_18h, 0x0E2F00); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_TR_26h, 0x444444); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_03h, 0x000000); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_06h, 0x2EBAEF); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_08h, 0x00000B); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_0Ch, 0x00504D); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_0Dh, 0x02314F); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_0Fh, 0x003028); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_10h, 0x005010); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_11h, 0x040001); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_13h, 0x018670); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_14h, 0x00024A); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_1Bh, 0x000072); ++ AIR_RTN_ERR(ret); ++ ret = airoha_tr_reg_write(phydev, RgAddr_DSPF_1Ch, 0x003210); ++ AIR_RTN_ERR(ret); ++ /* CL22 & CL45 */ ++ ret = airoha_cl22_write(mbus, phy_addr, 0x1f, 0x03); ++ AIR_RTN_ERR(ret); ++ GPHY_RG_LPI_1C.DATA = airoha_cl22_read(mbus, phy_addr, RgAddr_LPI_1Ch); ++ if (GPHY_RG_LPI_1C.DATA < 0) ++ return -EIO; ++ GPHY_RG_LPI_1C.DataBitField.smi_deton_th = 0x0C; ++ ret = airoha_cl22_write(mbus, phy_addr, RgAddr_LPI_1Ch, GPHY_RG_LPI_1C.DATA); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl22_write(mbus, phy_addr, RgAddr_LPI_1Ch, 0xC92); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl22_write(mbus, phy_addr, RgAddr_AUXILIARY_1Dh, 0x1); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl22_write(mbus, phy_addr, 0x1f, 0x0); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x120, 0x8014); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x122, 0xffff); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x123, 0xffff); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x144, 0x0200); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x14A, 0xEE20); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x189, 0x0110); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x19B, 0x0111); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x234, 0x0181); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x238, 0x0120); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x239, 0x0117); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x268, 0x07F4); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x2D1, 0x0733); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x323, 0x0011); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x324, 0x013F); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x326, 0x0037); ++ AIR_RTN_ERR(ret); ++ ++ reg_value = airoha_cl45_read(phydev, 0x1E, 0x324); ++ if (reg_value < 0) ++ return -EIO; ++ GPHY_RG_1E_324.DATA = (int)reg_value; ++ GPHY_RG_1E_324.DataBitField.smi_det_deglitch_off = 0; ++ ret = airoha_cl45_write(phydev, 0x1E, 0x324, GPHY_RG_1E_324.DATA); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x19E, 0xC2); ++ AIR_RTN_ERR(ret); ++ ret = airoha_cl45_write(phydev, 0x1E, 0x013, 0x0); ++ AIR_RTN_ERR(ret); ++ ++ /* EFUSE */ ++ airoha_pbus_write(mbus, pbus_addr, 0x1C08, 0x40000040); ++ retry = MAX_RETRY; ++ while (0 != retry) { ++ mdelay(1); ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1C08); ++ if ((pbus_data & (1 << 30)) == 0) { ++ break; ++ } ++ retry--; ++ } ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1C38); /* RAW#2 */ ++ reg_value = airoha_cl45_read(phydev, 0x1E, 0x12); ++ if (reg_value < 0) ++ return -EIO; ++ GPHY_RG_1E_012.DATA = reg_value; ++ GPHY_RG_1E_012.DataBitField.da_tx_i2mpb_a_tbt = pbus_data & 0x03f; ++ ret = airoha_cl45_write(phydev, 0x1E, 0x12, GPHY_RG_1E_012.DATA); ++ AIR_RTN_ERR(ret); ++ reg_value = airoha_cl45_read(phydev, 0x1E, 0x17); ++ if (reg_value < 0) ++ return -EIO; ++ GPHY_RG_1E_017.DataBitField.da_tx_i2mpb_b_tbt = (reg_value >> 8) & 0x03f; ++ ret = airoha_cl45_write(phydev, 0x1E, 0x17, GPHY_RG_1E_017.DATA); ++ AIR_RTN_ERR(ret); ++ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1C08, 0x40400040); ++ AIR_RTN_ERR(ret); ++ retry = MAX_RETRY; ++ while (0 != retry) { ++ mdelay(1); ++ reg_value = airoha_pbus_read(mbus, pbus_addr, 0x1C08); ++ if ((reg_value & (1 << 30)) == 0) { ++ break; ++ } ++ retry--; ++ } ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1C30); /* RAW#16 */ ++ GPHY_RG_1E_324.DataBitField.smi_det_deglitch_off = (pbus_data >> 12) & 0x01; ++ ret = airoha_cl45_write(phydev, 0x1E, 0x324, GPHY_RG_1E_324.DATA); ++ AIR_RTN_ERR(ret); ++#ifdef AIR_LED_SUPPORT ++ ret = en8801s_led_init(phydev); ++ if (ret != 0){ ++ printf("en8801s_led_init fail (ret:%d) !\n", ret); ++ } ++#endif ++ printf("EN8801S initialize OK ! (%s)\n", EN8801S_DRIVER_VERSION); ++ return 0; ++} ++ ++int en8801s_read_status(struct phy_device *phydev) ++{ ++ int ret, pbus_addr = EN8801S_PBUS_PHY_ID; ++ struct mii_dev *mbus; ++ unsigned long pbus_data; ++ ++ mbus = phydev->bus; ++ if (SPEED_10 == phydev->speed) { ++ /* set the bit for Optimze 10M IoT */ ++ debug("[Airoha] SPEED_10 0x1694\n"); ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1694); ++ pbus_data |= (1 << 31); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1694, pbus_data); ++ AIR_RTN_ERR(ret); ++ } else { ++ debug("[Airoha] SPEED_1000/100 0x1694\n"); ++ /* clear the bit for other speeds */ ++ pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1694); ++ pbus_data &= ~(1 << 31); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1694, pbus_data); ++ AIR_RTN_ERR(ret); ++ } ++ ++ airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c000c00); ++ if(SPEED_1000 == phydev->speed) { ++ debug("[Airoha] SPEED_1000\n"); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x10, 0xD801); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0, 0x9140); ++ AIR_RTN_ERR(ret); ++ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0A14, 0x0003); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c000c00); ++ AIR_RTN_ERR(ret); ++ mdelay(2); /* delay 2 ms */ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1404, 0x004b); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x140c, 0x0007); ++ AIR_RTN_ERR(ret); ++ } ++ else if (SPEED_100 == phydev->speed) { ++ debug("[Airoha] SPEED_100\n"); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x10, 0xD401); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0, 0x9140); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0A14, 0x0007); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c11); ++ AIR_RTN_ERR(ret); ++ mdelay(2); /* delay 2 ms */ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1404, 0x0027); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x140c, 0x0007); ++ AIR_RTN_ERR(ret); ++ } ++ else { ++ debug("[Airoha] SPEED_10\n"); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x10, 0xD001); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0, 0x9140); ++ AIR_RTN_ERR(ret); ++ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0A14, 0x000b); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x0600, 0x0c11); ++ AIR_RTN_ERR(ret); ++ mdelay(2); /* delay 2 ms */ ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x1404, 0x0047); ++ AIR_RTN_ERR(ret); ++ ret = airoha_pbus_write(mbus, pbus_addr, 0x140c, 0x0007); ++ AIR_RTN_ERR(ret); ++ } ++ return 0; ++} ++ ++static int en8801s_startup(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = genphy_update_link(phydev); ++ if (ret) ++ return ret; ++ ret = genphy_parse_link(phydev); ++ if (ret) ++ return ret; ++ return en8801s_read_status(phydev); ++} ++#if AIR_UBOOT_REVISION > 0x202303 ++U_BOOT_PHY_DRIVER(en8801s) = { ++ .name = "Airoha EN8801S", ++ .uid = EN8801S_PHY_ID, ++ .mask = 0x0ffffff0, ++ .features = PHY_GBIT_FEATURES, ++ .config = &en8801s_config, ++ .startup = &en8801s_startup, ++ .shutdown = &genphy_shutdown, ++}; ++#else ++static struct phy_driver AIR_EN8801S_driver = { ++ .name = "Airoha EN8801S", ++ .uid = EN8801S_PHY_ID, ++ .mask = 0x0ffffff0, ++ .features = PHY_GBIT_FEATURES, ++ .config = &en8801s_config, ++ .startup = &en8801s_startup, ++ .shutdown = &genphy_shutdown, ++}; ++ ++int phy_air_en8801s_init(void) ++{ ++ phy_register(&AIR_EN8801S_driver); ++ return 0; ++} ++#endif +--- /dev/null ++++ b/drivers/net/phy/air_en8801s.h +@@ -0,0 +1,267 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/************************************************* ++ * FILE NAME: air_en8801s.h ++ * PURPOSE: ++ * EN8801S PHY Driver for Uboot ++ * NOTES: ++ * ++ * Copyright (C) 2023 Airoha Technology Corp. ++ *************************************************/ ++ ++#ifndef __EN8801S_H ++#define __EN8801S_H ++ ++/************************************************************************ ++* D E F I N E S ++************************************************************************/ ++#define AIR_UBOOT_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 20) | \ ++ (((U_BOOT_VERSION_NUM / 100) % 10) << 16) | \ ++ (((U_BOOT_VERSION_NUM / 10) % 10) << 12) | \ ++ ((U_BOOT_VERSION_NUM % 10) << 8) | \ ++ (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 4) | \ ++ ((U_BOOT_VERSION_NUM_PATCH % 10) << 0)) ++ ++#define EN8801S_MDIO_DEFAULT_ID 0x1d ++#define EN8801S_PBUS_DEFAULT_ID (EN8801S_MDIO_DEFAULT_ID + 1) ++#define EN8801S_MDIO_PHY_ID 0x18 /* Range PHY_ADDRESS_RANGE .. 0x1e */ ++#define EN8801S_PBUS_PHY_ID (EN8801S_MDIO_PHY_ID + 1) ++#define EN8801S_DRIVER_VERSION "v1.1.3" ++ ++#define EN8801S_RG_ETHER_PHY_OUI 0x19a4 ++#define EN8801S_RG_SMI_ADDR 0x19a8 ++#define EN8801S_PBUS_OUI 0x17a5 ++#define EN8801S_RG_BUCK_CTL 0x1a20 ++#define EN8801S_RG_LTR_CTL 0x0cf8 ++ ++#define EN8801S_PHY_ID1 0x03a2 ++#define EN8801S_PHY_ID2 0x9461 ++#define EN8801S_PHY_ID (unsigned long)((EN8801S_PHY_ID1 << 16) | EN8801S_PHY_ID2) ++ ++/* ++SFP Sample for verification ++Tx Reverse, Rx Reverse ++*/ ++#define EN8801S_TX_POLARITY_NORMAL 0x0 ++#define EN8801S_TX_POLARITY_REVERSE 0x1 ++ ++#define EN8801S_RX_POLARITY_NORMAL (0x1 << 1) ++#define EN8801S_RX_POLARITY_REVERSE (0x0 << 1) ++ ++#ifndef BIT ++#define BIT(nr) (1UL << (nr)) ++#endif ++ ++#define MAX_RETRY 5 ++#define MAX_OUI_CHECK 2 ++ ++/* CL45 MDIO control */ ++#define MII_MMD_ACC_CTL_REG 0x0d ++#define MII_MMD_ADDR_DATA_REG 0x0e ++#define MMD_OP_MODE_DATA BIT(14) ++ ++#define MAX_TRG_COUNTER 5 ++ ++/* TokenRing Reg Access */ ++#define TrReg_PKT_XMT_STA 0x8000 ++#define TrReg_WR 0x8000 ++#define TrReg_RD 0xA000 ++ ++#define RgAddr_LPI_1Ch 0x1c ++#define RgAddr_AUXILIARY_1Dh 0x1d ++#define RgAddr_PMA_00h 0x0f80 ++#define RgAddr_PMA_01h 0x0f82 ++#define RgAddr_PMA_17h 0x0fae ++#define RgAddr_PMA_18h 0x0fb0 ++#define RgAddr_DSPF_03h 0x1686 ++#define RgAddr_DSPF_06h 0x168c ++#define RgAddr_DSPF_08h 0x1690 ++#define RgAddr_DSPF_0Ch 0x1698 ++#define RgAddr_DSPF_0Dh 0x169a ++#define RgAddr_DSPF_0Fh 0x169e ++#define RgAddr_DSPF_10h 0x16a0 ++#define RgAddr_DSPF_11h 0x16a2 ++#define RgAddr_DSPF_13h 0x16a6 ++#define RgAddr_DSPF_14h 0x16a8 ++#define RgAddr_DSPF_1Bh 0x16b6 ++#define RgAddr_DSPF_1Ch 0x16b8 ++#define RgAddr_TR_26h 0x0ecc ++#define RgAddr_R1000DEC_15h 0x03aa ++#define RgAddr_R1000DEC_17h 0x03ae ++ ++/* ++The following led_cfg example is for reference only. ++LED5 1000M/LINK/ACT (GPIO5) <-> BASE_T_LED0, ++LED6 10/100M/LINK/ACT(GPIO9) <-> BASE_T_LED1, ++LED4 100M/LINK/ACT (GPIO8) <-> BASE_T_LED2, ++*/ ++/* User-defined.B */ ++#define BASE_T_LED0_ON_CFG (LED_ON_EVT_LINK_1000M) ++#define BASE_T_LED0_BLK_CFG (LED_BLK_EVT_1000M_TX_ACT | LED_BLK_EVT_1000M_RX_ACT) ++#define BASE_T_LED1_ON_CFG (LED_ON_EVT_LINK_100M | LED_ON_EVT_LINK_10M) ++#define BASE_T_LED1_BLK_CFG (LED_BLK_EVT_100M_TX_ACT | LED_BLK_EVT_100M_RX_ACT | \ ++ LED_BLK_EVT_10M_TX_ACT | LED_BLK_EVT_10M_RX_ACT ) ++#define BASE_T_LED2_ON_CFG (LED_ON_EVT_LINK_100M) ++#define BASE_T_LED2_BLK_CFG (LED_BLK_EVT_100M_TX_ACT | LED_BLK_EVT_100M_RX_ACT) ++#define BASE_T_LED3_ON_CFG (0x0) ++#define BASE_T_LED3_BLK_CFG (0x0) ++/* User-defined.E */ ++ ++#define EN8801S_LED_COUNT 4 ++ ++#define LED_BCR (0x021) ++#define LED_BCR_EXT_CTRL (1 << 15) ++#define LED_BCR_CLK_EN (1 << 3) ++#define LED_BCR_TIME_TEST (1 << 2) ++#define LED_BCR_MODE_MASK (3) ++#define LED_BCR_MODE_DISABLE (0) ++#define LED_ON_CTRL(i) (0x024 + ((i)*2)) ++#define LED_ON_EN (1 << 15) ++#define LED_ON_POL (1 << 14) ++#define LED_ON_EVT_MASK (0x7f) ++/* LED ON Event Option.B */ ++#define LED_ON_EVT_FORCE (1 << 6) ++#define LED_ON_EVT_LINK_DOWN (1 << 3) ++#define LED_ON_EVT_LINK_10M (1 << 2) ++#define LED_ON_EVT_LINK_100M (1 << 1) ++#define LED_ON_EVT_LINK_1000M (1 << 0) ++/* LED ON Event Option.E */ ++#define LED_BLK_CTRL(i) (0x025 + ((i)*2)) ++#define LED_BLK_EVT_MASK (0x3ff) ++/* LED Blinking Event Option.B*/ ++#define LED_BLK_EVT_FORCE (1 << 9) ++#define LED_BLK_EVT_10M_RX_ACT (1 << 5) ++#define LED_BLK_EVT_10M_TX_ACT (1 << 4) ++#define LED_BLK_EVT_100M_RX_ACT (1 << 3) ++#define LED_BLK_EVT_100M_TX_ACT (1 << 2) ++#define LED_BLK_EVT_1000M_RX_ACT (1 << 1) ++#define LED_BLK_EVT_1000M_TX_ACT (1 << 0) ++/* LED Blinking Event Option.E*/ ++#define LED_ON_DUR (0x022) ++#define LED_ON_DUR_MASK (0xffff) ++#define LED_BLK_DUR (0x023) ++#define LED_BLK_DUR_MASK (0xffff) ++ ++#define LED_ENABLE 1 ++#define LED_DISABLE 0 ++ ++#define UNIT_LED_BLINK_DURATION 1024 ++ ++#define AIR_RTN_ON_ERR(cond, err) \ ++ do { if ((cond)) return (err); } while(0) ++ ++#define AIR_RTN_ERR(err) AIR_RTN_ON_ERR(err < 0, err) ++ ++#define LED_SET_EVT(reg, cod, result, bit) do \ ++ { \ ++ if(reg & cod) { \ ++ result |= bit; \ ++ } \ ++ } while(0) ++ ++#define LED_SET_GPIO_SEL(gpio, led, val) do \ ++ { \ ++ val |= (led << (8 * (gpio % 4))); \ ++ } while(0) ++ ++/* DATA TYPE DECLARATIONS ++ */ ++typedef struct ++{ ++ int DATA_Lo; ++ int DATA_Hi; ++}TR_DATA_T; ++ ++typedef union ++{ ++ struct ++ { ++ /* b[15:00] */ ++ int smi_deton_wt : 3; ++ int smi_det_mdi_inv : 1; ++ int smi_detoff_wt : 3; ++ int smi_sigdet_debouncing_en : 1; ++ int smi_deton_th : 6; ++ int rsv_14 : 2; ++ } DataBitField; ++ int DATA; ++} gephy_all_REG_LpiReg1Ch, *Pgephy_all_REG_LpiReg1Ch; ++ ++typedef union ++{ ++ struct ++ { ++ /* b[15:00] */ ++ int rg_smi_detcnt_max : 6; ++ int rsv_6 : 2; ++ int rg_smi_det_max_en : 1; ++ int smi_det_deglitch_off : 1; ++ int rsv_10 : 6; ++ } DataBitField; ++ int DATA; ++} gephy_all_REG_dev1Eh_reg324h, *Pgephy_all_REG_dev1Eh_reg324h; ++ ++typedef union ++{ ++ struct ++ { ++ /* b[15:00] */ ++ int da_tx_i2mpb_a_tbt : 6; ++ int rsv_6 : 4; ++ int da_tx_i2mpb_a_gbe : 6; ++ } DataBitField; ++ int DATA; ++} gephy_all_REG_dev1Eh_reg012h, *Pgephy_all_REG_dev1Eh_reg012h; ++ ++typedef union ++{ ++ struct ++ { ++ /* b[15:00] */ ++ int da_tx_i2mpb_b_tbt : 6; ++ int rsv_6 : 2; ++ int da_tx_i2mpb_b_gbe : 6; ++ int rsv_14 : 2; ++ } DataBitField; ++ int DATA; ++} gephy_all_REG_dev1Eh_reg017h, *Pgephy_all_REG_dev1Eh_reg017h; ++ ++typedef struct AIR_BASE_T_LED_CFG_S ++{ ++ u16 en; ++ u16 gpio; ++ u16 pol; ++ u16 on_cfg; ++ u16 blk_cfg; ++}AIR_BASE_T_LED_CFG_T; ++ ++typedef enum ++{ ++ AIR_LED_BLK_DUR_32M, ++ AIR_LED_BLK_DUR_64M, ++ AIR_LED_BLK_DUR_128M, ++ AIR_LED_BLK_DUR_256M, ++ AIR_LED_BLK_DUR_512M, ++ AIR_LED_BLK_DUR_1024M, ++ AIR_LED_BLK_DUR_LAST ++} AIR_LED_BLK_DUT_T; ++ ++typedef enum ++{ ++ AIR_ACTIVE_LOW, ++ AIR_ACTIVE_HIGH, ++} AIR_LED_POLARITY; ++typedef enum ++{ ++ AIR_LED_MODE_DISABLE, ++ AIR_LED_MODE_USER_DEFINE, ++ AIR_LED_MODE_LAST ++} AIR_LED_MODE_T; ++ ++/************************************************************************ ++* F U N C T I O N P R O T O T Y P E S ++************************************************************************/ ++ ++unsigned long airoha_pbus_read(struct mii_dev *bus, int pbus_addr, int pbus_reg); ++int airoha_pbus_write(struct mii_dev *bus, int pbus_addr, int pbus_reg, unsigned long pbus_data); ++int airoha_phy_process(void); ++#endif /* __EN8801S_H */ +--- /dev/null ++++ b/drivers/net/phy/air_en8811h.c +@@ -0,0 +1,725 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/************************************************* ++ * FILE NAME: air_en8811h.c ++ * PURPOSE: ++ * EN8811H PHY Driver for Uboot ++ * NOTES: ++ * ++ * Copyright (C) 2023 Airoha Technology Corp. ++ *************************************************/ ++ ++/* INCLUDE FILE DECLARATIONS ++*/ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "air_en8811h.h" ++ ++#ifdef CONFIG_PHY_AIROHA_FW_IN_UBI ++#include ++#endif ++ ++#ifdef CONFIG_PHY_AIROHA_FW_IN_MMC ++#include ++#endif ++ ++#ifdef CONFIG_PHY_AIROHA_FW_IN_MTD ++#include ++#endif ++ ++#if AIR_UBOOT_REVISION > 0x202004 ++#include ++#endif ++ ++/************************** ++ * GPIO5 <-> BASE_T_LED0, ++ * GPIO4 <-> BASE_T_LED1, ++ * GPIO3 <-> BASE_T_LED2, ++ **************************/ ++/* User-defined.B */ ++#define AIR_LED_SUPPORT ++#ifdef AIR_LED_SUPPORT ++static const struct air_base_t_led_cfg_s led_cfg[3] = { ++/********************************************************************* ++ *Enable, GPIO, LED Polarity, LED ON, LED Blink ++**********************************************************************/ ++ {1, AIR_LED0_GPIO5, AIR_ACTIVE_HIGH, AIR_LED0_ON, AIR_LED0_BLK}, ++ {1, AIR_LED1_GPIO4, AIR_ACTIVE_HIGH, AIR_LED1_ON, AIR_LED1_BLK}, ++ {1, AIR_LED2_GPIO3, AIR_ACTIVE_HIGH, AIR_LED2_ON, AIR_LED2_BLK}, ++}; ++static const u16 led_dur = UNIT_LED_BLINK_DURATION << AIR_LED_BLK_DUR_64M; ++#endif ++/* User-defined.E */ ++/************************************************************* ++ * F U N C T I O N S ++ **************************************************************/ ++/* Airoha MII read function */ ++static int air_mii_cl22_read(struct mii_dev *bus, int phy_addr, int phy_register) ++{ ++ int read_data = bus->read(bus, phy_addr, MDIO_DEVAD_NONE, phy_register); ++ ++ if (read_data < 0) ++ return -EIO; ++ return read_data; ++} ++ ++/* Airoha MII write function */ ++static int air_mii_cl22_write(struct mii_dev *bus, int phy_addr, int phy_register, int write_data) ++{ ++ int ret = 0; ++ ++ ret = bus->write(bus, phy_addr, MDIO_DEVAD_NONE, phy_register, write_data); ++ if (ret < 0) { ++ printf("bus->write, ret: %d\n", ret); ++ return ret; ++ } ++ return ret; ++} ++ ++static int air_mii_cl45_read(struct phy_device *phydev, int devad, u16 reg) ++{ ++ int ret = 0; ++ int data; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, devad); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return INVALID_DATA; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, reg); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return INVALID_DATA; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, MMD_OP_MODE_DATA | devad); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return INVALID_DATA; ++ } ++ data = phy_read(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG); ++ return data; ++} ++ ++static int air_mii_cl45_write(struct phy_device *phydev, int devad, u16 reg, u16 write_data) ++{ ++ int ret = 0; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, devad); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, reg); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ACC_CTL_REG, MMD_OP_MODE_DATA | devad); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_ADDR_DATA_REG, write_data); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ return 0; ++} ++/* Use default PBUS_PHY_ID */ ++/* EN8811H PBUS write function */ ++static int air_pbus_reg_write(struct phy_device *phydev, unsigned long pbus_address, unsigned long pbus_data) ++{ ++ int ret = 0; ++ struct mii_dev *mbus = phydev->bus; ++ ++ ret = air_mii_cl22_write(mbus, ((phydev->addr) + 8), 0x1F, (unsigned int)(pbus_address >> 6)); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl22_write(mbus, ((phydev->addr) + 8), (unsigned int)((pbus_address >> 2) & 0xf), (unsigned int)(pbus_data & 0xFFFF)); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl22_write(mbus, ((phydev->addr) + 8), 0x10, (unsigned int)(pbus_data >> 16)); ++ if (ret < 0) ++ return ret; ++ return 0; ++} ++ ++/* EN8811H BUCK write function */ ++static int air_buckpbus_reg_write(struct phy_device *phydev, unsigned long pbus_address, unsigned int pbus_data) ++{ ++ int ret = 0; ++ ++ /* page 4 */ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, (unsigned int)4); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x10, (unsigned int)0); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x11, (unsigned int)((pbus_address >> 16) & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x12, (unsigned int)(pbus_address & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x13, (unsigned int)((pbus_data >> 16) & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x14, (unsigned int)(pbus_data & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ return 0; ++} ++ ++/* EN8811H BUCK read function */ ++static unsigned int air_buckpbus_reg_read(struct phy_device *phydev, unsigned long pbus_address) ++{ ++ unsigned int pbus_data = 0, pbus_data_low, pbus_data_high; ++ int ret = 0; ++ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, (unsigned int)4); /* page 4 */ ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return PBUS_INVALID_DATA; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x10, (unsigned int)0); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return PBUS_INVALID_DATA; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x15, (unsigned int)((pbus_address >> 16) & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return PBUS_INVALID_DATA; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x16, (unsigned int)(pbus_address & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return PBUS_INVALID_DATA; ++ } ++ ++ pbus_data_high = phy_read(phydev, MDIO_DEVAD_NONE, 0x17); ++ pbus_data_low = phy_read(phydev, MDIO_DEVAD_NONE, 0x18); ++ pbus_data = (pbus_data_high << 16) + pbus_data_low; ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, (unsigned int)0); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ return pbus_data; ++} ++ ++static int MDIOWriteBuf(struct phy_device *phydev, unsigned long address, unsigned long array_size, const unsigned char *buffer) ++{ ++ unsigned int write_data, offset ; ++ int ret = 0; ++ ++ /* page 4 */ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, (unsigned int)4); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ /* address increment*/ ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x10, (unsigned int)0x8000); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x11, (unsigned int)((address >> 16) & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x12, (unsigned int)(address & 0xffff)); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ ++ for (offset = 0; offset < array_size; offset += 4) { ++ write_data = (buffer[offset + 3] << 8) | buffer[offset + 2]; ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x13, write_data); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ write_data = (buffer[offset + 1] << 8) | buffer[offset]; ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x14, write_data); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ } ++ ret = phy_write(phydev, MDIO_DEVAD_NONE, 0x1F, (unsigned int)0); ++ if (ret < 0) { ++ printf("phy_write, ret: %d\n", ret); ++ return ret; ++ } ++ return 0; ++} ++ ++#ifdef AIR_LED_SUPPORT ++static int airoha_led_set_usr_def(struct phy_device *phydev, u8 entity, int polar, ++ u16 on_evt, u16 blk_evt) ++{ ++ int ret = 0; ++ ++ if (AIR_ACTIVE_HIGH == polar) ++ on_evt |= LED_ON_POL; ++ else ++ on_evt &= ~LED_ON_POL; ++ ++ ret = air_mii_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), on_evt | LED_ON_EN); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl45_write(phydev, 0x1f, LED_BLK_CTRL(entity), blk_evt); ++ if (ret < 0) ++ return ret; ++ return 0; ++} ++ ++static int airoha_led_set_mode(struct phy_device *phydev, u8 mode) ++{ ++ u16 cl45_data; ++ int err = 0; ++ ++ cl45_data = air_mii_cl45_read(phydev, 0x1f, LED_BCR); ++ switch (mode) { ++ case AIR_LED_MODE_DISABLE: ++ cl45_data &= ~LED_BCR_EXT_CTRL; ++ cl45_data &= ~LED_BCR_MODE_MASK; ++ cl45_data |= LED_BCR_MODE_DISABLE; ++ break; ++ case AIR_LED_MODE_USER_DEFINE: ++ cl45_data |= LED_BCR_EXT_CTRL; ++ cl45_data |= LED_BCR_CLK_EN; ++ break; ++ default: ++ printf("LED mode%d is not supported!\n", mode); ++ return -EINVAL; ++ } ++ err = air_mii_cl45_write(phydev, 0x1f, LED_BCR, cl45_data); ++ if (err < 0) ++ return err; ++ return 0; ++} ++ ++static int airoha_led_set_state(struct phy_device *phydev, u8 entity, u8 state) ++{ ++ u16 cl45_data; ++ int err; ++ ++ cl45_data = air_mii_cl45_read(phydev, 0x1f, LED_ON_CTRL(entity)); ++ if (LED_ENABLE == state) ++ cl45_data |= LED_ON_EN; ++ else ++ cl45_data &= ~LED_ON_EN; ++ ++ err = air_mii_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), cl45_data); ++ if (err < 0) ++ return err; ++ return 0; ++} ++ ++static int en8811h_led_init(struct phy_device *phydev) ++{ ++ unsigned int led_gpio = 0, reg_value = 0; ++ u16 cl45_data = led_dur; ++ int ret, led_id; ++ ++ cl45_data = UNIT_LED_BLINK_DURATION << AIR_LED_BLK_DUR_64M; ++ ret = air_mii_cl45_write(phydev, 0x1f, LED_BLK_DUR, cl45_data); ++ if (ret < 0) ++ return ret; ++ cl45_data >>= 1; ++ ret = air_mii_cl45_write(phydev, 0x1f, LED_ON_DUR, cl45_data); ++ if (ret < 0) ++ return ret; ++ ++ ret = airoha_led_set_mode(phydev, AIR_LED_MODE_USER_DEFINE); ++ if (ret != 0) { ++ printf("LED fail to set mode, ret %d !\n", ret); ++ return ret; ++ } ++ for(led_id = 0; led_id < EN8811H_LED_COUNT; led_id++) ++ { ++ /* LED0 <-> GPIO5, LED1 <-> GPIO4, LED0 <-> GPIO3 */ ++ if ( led_cfg[led_id].gpio != (led_id + (AIR_LED0_GPIO5 - (2 * led_id)))) { ++ printf("LED%d uses incorrect GPIO%d !\n", led_id, led_cfg[led_id].gpio); ++ return -EINVAL; ++ } ++ reg_value = 0; ++ if (led_cfg[led_id].en == LED_ENABLE) ++ { ++ led_gpio |= BIT(led_cfg[led_id].gpio); ++ ret = airoha_led_set_state(phydev, led_id, led_cfg[led_id].en); ++ if (ret != 0) { ++ printf("LED fail to set state, ret %d !\n", ret); ++ return ret; ++ } ++ ret = airoha_led_set_usr_def(phydev, led_id, led_cfg[led_id].pol, led_cfg[led_id].on_cfg, led_cfg[led_id].blk_cfg); ++ if (ret != 0) { ++ printf("LED fail to set default, ret %d !\n", ret); ++ return ret; ++ } ++ } ++ } ++ ret = air_buckpbus_reg_write(phydev, 0xcf8b8, led_gpio); ++ if (ret < 0) ++ return ret; ++ printf("LED initialize OK !\n"); ++ return 0; ++} ++#endif /* AIR_LED_SUPPORT */ ++ ++static char *firmware_buf; ++static int en8811h_load_firmware(struct phy_device *phydev) ++{ ++ u32 pbus_value; ++ int ret = 0; ++ ++ if (!firmware_buf) { ++ firmware_buf = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE); ++ if (!firmware_buf) { ++ printf("[Airoha] cannot allocated buffer for firmware.\n"); ++ return -ENOMEM; ++ } ++ ++#ifdef CONFIG_PHY_AIROHA_FW_IN_UBI ++ ret = ubi_volume_read("en8811h-fw", firmware_buf, EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE); ++ if (ret) { ++ printf("[Airoha] read firmware from UBI failed.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return ret; ++ } ++#elif defined(CONFIG_PHY_AIROHA_FW_IN_MMC) ++ struct mmc *mmc = find_mmc_device(0); ++ if (!mmc) { ++ printf("[Airoha] opening MMC device failed.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return -ENODEV; ++ } ++ if (mmc_init(mmc)) { ++ printf("[Airoha] initializing MMC device failed.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return -ENODEV; ++ } ++ if (IS_SD(mmc)) { ++ printf("[Airoha] SD card is not supported.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return -EINVAL; ++ } ++ ret = mmc_set_part_conf(mmc, 1, 2, 2); ++ if (ret) { ++ printf("[Airoha] cannot access eMMC boot1 hw partition.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return ret; ++ } ++ ret = blk_dread(mmc_get_blk_desc(mmc), 0, 0x120, firmware_buf); ++ mmc_set_part_conf(mmc, 1, 1, 0); ++ if (ret != 0x120) { ++ printf("[Airoha] cannot read firmware from eMMC.\n"); ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return -EIO; ++ } ++#else ++#warning EN8811H firmware loading not implemented ++ free(firmware_buf); ++ firmware_buf = NULL; ++ return -EOPNOTSUPP; ++#endif ++ } ++ ++ ret = air_buckpbus_reg_write(phydev, 0x0f0018, 0x0); ++ if (ret < 0) ++ return ret; ++ pbus_value = air_buckpbus_reg_read(phydev, 0x800000); ++ pbus_value |= BIT(11); ++ ret = air_buckpbus_reg_write(phydev, 0x800000, pbus_value); ++ if (ret < 0) ++ return ret; ++ /* Download DM */ ++ ret = MDIOWriteBuf(phydev, 0x00000000, EN8811H_MD32_DM_SIZE, firmware_buf); ++ if (ret < 0) { ++ printf("[Airoha] MDIOWriteBuf 0x00000000 fail.\n"); ++ return ret; ++ } ++ /* Download PM */ ++ ret = MDIOWriteBuf(phydev, 0x00100000, EN8811H_MD32_DSP_SIZE, firmware_buf + EN8811H_MD32_DM_SIZE); ++ if (ret < 0) { ++ printf("[Airoha] MDIOWriteBuf 0x00100000 fail.\n"); ++ return ret; ++ } ++ pbus_value = air_buckpbus_reg_read(phydev, 0x800000); ++ pbus_value &= ~BIT(11); ++ ret = air_buckpbus_reg_write(phydev, 0x800000, pbus_value); ++ if (ret < 0) ++ return ret; ++ ret = air_buckpbus_reg_write(phydev, 0x0f0018, 0x01); ++ if (ret < 0) ++ return ret; ++ return 0; ++} ++ ++static int en8811h_config(struct phy_device *phydev) ++{ ++ int ret = 0; ++ int pid1 = 0, pid2 = 0; ++ ++ ret = air_pbus_reg_write(phydev, 0xcf928 , 0x0); ++ if (ret < 0) ++ return ret; ++ ++ pid1 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1); ++ pid2 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID2); ++ if ((EN8811H_PHY_ID1 != pid1) || (EN8811H_PHY_ID2 != pid2)) { ++ printf("EN8811H does not exist !\n"); ++ return -ENODEV; ++ } ++ ++ return 0; ++} ++ ++static int en8811h_get_autonego(struct phy_device *phydev, int *an) ++{ ++ int reg; ++ reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR); ++ if (reg < 0) ++ return -EINVAL; ++ if (reg & BMCR_ANENABLE) ++ *an = AUTONEG_ENABLE; ++ else ++ *an = AUTONEG_DISABLE; ++ return 0; ++} ++ ++static int en8811h_startup(struct phy_device *phydev) ++{ ++ ofnode node = phy_get_ofnode(phydev); ++ int ret = 0, lpagb = 0, lpa = 0, common_adv_gb = 0, common_adv = 0, advgb = 0, adv = 0, reg = 0, an = AUTONEG_DISABLE, bmcr = 0, reg_value; ++ int old_link = phydev->link; ++ u32 pbus_value = 0, retry; ++ ++ eth_phy_reset(phydev->dev, 1); ++ mdelay(10); ++ eth_phy_reset(phydev->dev, 0); ++ mdelay(1); ++ ++ ret = en8811h_load_firmware(phydev); ++ if (ret) { ++ printf("EN8811H load firmware fail.\n"); ++ return ret; ++ } ++ retry = MAX_RETRY; ++ do { ++ mdelay(300); ++ reg_value = air_mii_cl45_read(phydev, 0x1e, 0x8009); ++ if (EN8811H_PHY_READY == reg_value) { ++ printf("EN8811H PHY ready!\n"); ++ break; ++ } ++ retry--; ++ } while (retry); ++ if (0 == retry) { ++ printf("EN8811H PHY is not ready. (MD32 FW Status reg: 0x%x)\n", reg_value); ++ pbus_value = air_buckpbus_reg_read(phydev, 0x3b3c); ++ printf("Check MD32 FW Version(0x3b3c) : %08x\n", pbus_value); ++ printf("EN8811H initialize fail!\n"); ++ return 0; ++ } ++ /* Mode selection*/ ++ printf("EN8811H Mode 1 !\n"); ++ ret = air_mii_cl45_write(phydev, 0x1e, 0x800c, 0x0); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl45_write(phydev, 0x1e, 0x800d, 0x0); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl45_write(phydev, 0x1e, 0x800e, 0x1101); ++ if (ret < 0) ++ return ret; ++ ret = air_mii_cl45_write(phydev, 0x1e, 0x800f, 0x0002); ++ if (ret < 0) ++ return ret; ++ ++ /* Serdes polarity */ ++ pbus_value = air_buckpbus_reg_read(phydev, 0xca0f8); ++ pbus_value &= 0xfffffffc; ++ pbus_value |= ofnode_read_bool(node, "airoha,rx-pol-reverse") ? ++ EN8811H_RX_POLARITY_REVERSE : EN8811H_RX_POLARITY_NORMAL; ++ pbus_value |= ofnode_read_bool(node, "airoha,tx-pol-reverse") ? ++ EN8811H_TX_POLARITY_REVERSE : EN8811H_TX_POLARITY_NORMAL; ++ ret = air_buckpbus_reg_write(phydev, 0xca0f8, pbus_value); ++ if (ret < 0) ++ return ret; ++ pbus_value = air_buckpbus_reg_read(phydev, 0xca0f8); ++ printf("Tx, Rx Polarity(0xca0f8): %08x\n", pbus_value); ++ pbus_value = air_buckpbus_reg_read(phydev, 0x3b3c); ++ printf("MD32 FW Version(0x3b3c) : %08x\n", pbus_value); ++#if defined(AIR_LED_SUPPORT) ++ ret = en8811h_led_init(phydev); ++ if (ret < 0) { ++ printf("en8811h_led_init fail\n"); ++ } ++#endif ++ printf("EN8811H initialize OK ! (%s)\n", EN8811H_DRIVER_VERSION); ++ ++ ret = genphy_update_link(phydev); ++ if (ret) ++ { ++ printf("ret %d!\n", ret); ++ return ret; ++ } ++ ++ ret = genphy_parse_link(phydev); ++ if (ret) ++ { ++ printf("ret %d!\n", ret); ++ return ret; ++ } ++ ++ if (old_link && phydev->link) ++ return 0; ++ ++ phydev->speed = SPEED_100; ++ phydev->duplex = DUPLEX_FULL; ++ phydev->pause = 0; ++ phydev->asym_pause = 0; ++ ++ reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR); ++ if (reg < 0) ++ { ++ printf("MII_BMSR reg %d!\n", reg); ++ return reg; ++ } ++ reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR); ++ if (reg < 0) ++ { ++ printf("MII_BMSR reg %d!\n", reg); ++ return reg; ++ } ++ if(reg & BMSR_LSTATUS) ++ { ++ pbus_value = air_buckpbus_reg_read(phydev, 0x109D4); ++ if (0x10 & pbus_value) { ++ phydev->speed = SPEED_2500; ++ phydev->duplex = DUPLEX_FULL; ++ } ++ else ++ { ++ ret = en8811h_get_autonego(phydev, &an); ++ if ((AUTONEG_ENABLE == an) && (0 == ret)) ++ { ++ printf("AN mode!\n"); ++ printf("SPEED 1000/100!\n"); ++ lpagb = phy_read(phydev, MDIO_DEVAD_NONE, MII_STAT1000); ++ if (lpagb < 0 ) ++ return lpagb; ++ advgb = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000); ++ if (adv < 0 ) ++ return adv; ++ common_adv_gb = (lpagb & (advgb << 2)); ++ ++ lpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_LPA); ++ if (lpa < 0 ) ++ return lpa; ++ adv = phy_read(phydev, MDIO_DEVAD_NONE, MII_ADVERTISE); ++ if (adv < 0 ) ++ return adv; ++ common_adv = (lpa & adv); ++ ++ phydev->speed = SPEED_10; ++ phydev->duplex = DUPLEX_HALF; ++ if (common_adv_gb & (LPA_1000FULL | LPA_1000HALF)) ++ { ++ phydev->speed = SPEED_1000; ++ if (common_adv_gb & LPA_1000FULL) ++ ++ phydev->duplex = DUPLEX_FULL; ++ } ++ else if (common_adv & (LPA_100FULL | LPA_100HALF)) ++ { ++ phydev->speed = SPEED_100; ++ if (common_adv & LPA_100FULL) ++ phydev->duplex = DUPLEX_FULL; ++ } ++ else ++ { ++ if (common_adv & LPA_10FULL) ++ phydev->duplex = DUPLEX_FULL; ++ } ++ } ++ else ++ { ++ printf("Force mode!\n"); ++ bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR); ++ ++ if (bmcr < 0) ++ return bmcr; ++ ++ if (bmcr & BMCR_FULLDPLX) ++ phydev->duplex = DUPLEX_FULL; ++ else ++ phydev->duplex = DUPLEX_HALF; ++ ++ if (bmcr & BMCR_SPEED1000) ++ phydev->speed = SPEED_1000; ++ else if (bmcr & BMCR_SPEED100) ++ phydev->speed = SPEED_100; ++ else ++ phydev->speed = SPEED_100; ++ } ++ } ++ } ++ ++ return ret; ++} ++ ++#if AIR_UBOOT_REVISION > 0x202303 ++U_BOOT_PHY_DRIVER(en8811h) = { ++ .name = "Airoha EN8811H", ++ .uid = EN8811H_PHY_ID, ++ .mask = 0x0ffffff0, ++ .config = &en8811h_config, ++ .startup = &en8811h_startup, ++ .shutdown = &genphy_shutdown, ++}; ++#else ++static struct phy_driver AIR_EN8811H_driver = { ++ .name = "Airoha EN8811H", ++ .uid = EN8811H_PHY_ID, ++ .mask = 0x0ffffff0, ++ .config = &en8811h_config, ++ .startup = &en8811h_startup, ++ .shutdown = &genphy_shutdown, ++}; ++ ++int phy_air_en8811h_init(void) ++{ ++ phy_register(&AIR_EN8811H_driver); ++ return 0; ++} ++#endif +--- /dev/null ++++ b/drivers/net/phy/air_en8811h.h +@@ -0,0 +1,163 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/************************************************* ++ * FILE NAME: air_en8811h.h ++ * PURPOSE: ++ * EN8811H PHY Driver for Uboot ++ * NOTES: ++ * ++ * Copyright (C) 2023 Airoha Technology Corp. ++ *************************************************/ ++ ++#ifndef __EN8811H_H ++#define __EN8811H_H ++ ++#define AIR_UBOOT_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 20) | \ ++ (((U_BOOT_VERSION_NUM / 100) % 10) << 16) | \ ++ (((U_BOOT_VERSION_NUM / 10) % 10) << 12) | \ ++ ((U_BOOT_VERSION_NUM % 10) << 8) | \ ++ (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 4) | \ ++ ((U_BOOT_VERSION_NUM_PATCH % 10) << 0)) ++ ++#define EN8811H_PHY_ID1 0x03a2 ++#define EN8811H_PHY_ID2 0xa411 ++#define EN8811H_PHY_ID ((EN8811H_PHY_ID1 << 16) | EN8811H_PHY_ID2) ++#define EN8811H_SPEED_2500 0x03 ++#define EN8811H_PHY_READY 0x02 ++#define MAX_RETRY 5 ++ ++#define EN8811H_MD32_DM_SIZE 0x4000 ++#define EN8811H_MD32_DSP_SIZE 0x20000 ++ ++#define EN8811H_TX_POLARITY_NORMAL 0x1 ++#define EN8811H_TX_POLARITY_REVERSE 0x0 ++ ++#define EN8811H_RX_POLARITY_NORMAL (0x0 << 1) ++#define EN8811H_RX_POLARITY_REVERSE (0x1 << 1) ++ ++#ifndef BIT ++#define BIT(nr) (1UL << (nr)) ++#endif ++ ++/* CL45 MDIO control */ ++#define MII_MMD_ACC_CTL_REG 0x0d ++#define MII_MMD_ADDR_DATA_REG 0x0e ++#define MMD_OP_MODE_DATA BIT(14) ++/* MultiGBASE-T AN register */ ++#define MULTIG_ANAR_2500M (0x0080) ++#define MULTIG_LPAR_2500M (0x0020) ++ ++#define EN8811H_DRIVER_VERSION "v1.0.4" ++ ++/************************************************************ ++ * For reference only ++ * LED0 Link 2500/Blink 2500 TxRx (GPIO5) <-> BASE_T_LED0, ++ * LED1 Link 1000/Blink 1000 TxRx (GPIO4) <-> BASE_T_LED1, ++ * LED2 Link 100/Blink 100 TxRx (GPIO3) <-> BASE_T_LED2, ++ ************************************************************/ ++/* User-defined.B */ ++#define AIR_LED0_ON (LED_ON_EVT_LINK_2500M) ++#define AIR_LED0_BLK (LED_BLK_EVT_2500M_TX_ACT | LED_BLK_EVT_2500M_RX_ACT) ++#define AIR_LED1_ON (LED_ON_EVT_LINK_1000M) ++#define AIR_LED1_BLK (LED_BLK_EVT_1000M_TX_ACT | LED_BLK_EVT_1000M_RX_ACT) ++#define AIR_LED2_ON (LED_ON_EVT_LINK_100M) ++#define AIR_LED2_BLK (LED_BLK_EVT_100M_TX_ACT | LED_BLK_EVT_100M_RX_ACT) ++/* User-defined.E */ ++ ++#define LED_ON_CTRL(i) (0x024 + ((i)*2)) ++#define LED_ON_EN (1 << 15) ++#define LED_ON_POL (1 << 14) ++#define LED_ON_EVT_MASK (0x1ff) ++/* LED ON Event Option.B */ ++#define LED_ON_EVT_LINK_2500M (1 << 8) ++#define LED_ON_EVT_FORCE (1 << 6) ++#define LED_ON_EVT_HDX (1 << 5) ++#define LED_ON_EVT_FDX (1 << 4) ++#define LED_ON_EVT_LINK_DOWN (1 << 3) ++#define LED_ON_EVT_LINK_100M (1 << 1) ++#define LED_ON_EVT_LINK_1000M (1 << 0) ++/* LED ON Event Option.E */ ++ ++#define LED_BLK_CTRL(i) (0x025 + ((i)*2)) ++#define LED_BLK_EVT_MASK (0xfff) ++/* LED Blinking Event Option.B*/ ++#define LED_BLK_EVT_2500M_RX_ACT (1 << 11) ++#define LED_BLK_EVT_2500M_TX_ACT (1 << 10) ++#define LED_BLK_EVT_FORCE (1 << 9) ++#define LED_BLK_EVT_100M_RX_ACT (1 << 3) ++#define LED_BLK_EVT_100M_TX_ACT (1 << 2) ++#define LED_BLK_EVT_1000M_RX_ACT (1 << 1) ++#define LED_BLK_EVT_1000M_TX_ACT (1 << 0) ++/* LED Blinking Event Option.E*/ ++#define LED_ENABLE 1 ++#define LED_DISABLE 0 ++ ++#define EN8811H_LED_COUNT 3 ++ ++#define LED_BCR (0x021) ++#define LED_BCR_EXT_CTRL (1 << 15) ++#define LED_BCR_CLK_EN (1 << 3) ++#define LED_BCR_TIME_TEST (1 << 2) ++#define LED_BCR_MODE_MASK (3) ++#define LED_BCR_MODE_DISABLE (0) ++#define LED_BCR_MODE_2LED (1) ++#define LED_BCR_MODE_3LED_1 (2) ++#define LED_BCR_MODE_3LED_2 (3) ++ ++#define LED_ON_DUR (0x022) ++#define LED_ON_DUR_MASK (0xffff) ++ ++#define LED_BLK_DUR (0x023) ++#define LED_BLK_DUR_MASK (0xffff) ++ ++#define LED_GPIO_SEL_MASK 0x7FFFFFF ++ ++#define UNIT_LED_BLINK_DURATION 1024 ++ ++#define INVALID_DATA 0xffff ++#define PBUS_INVALID_DATA 0xffffffff ++ ++struct air_base_t_led_cfg_s { ++ u16 en; ++ u16 gpio; ++ u16 pol; ++ u16 on_cfg; ++ u16 blk_cfg; ++}; ++ ++enum { ++ AIR_LED2_GPIO3 = 3, ++ AIR_LED1_GPIO4, ++ AIR_LED0_GPIO5, ++ AIR_LED_LAST ++}; ++ ++enum { ++ AIR_BASE_T_LED0, ++ AIR_BASE_T_LED1, ++ AIR_BASE_T_LED2, ++ AIR_BASE_T_LED3 ++}; ++ ++enum { ++ AIR_LED_BLK_DUR_32M, ++ AIR_LED_BLK_DUR_64M, ++ AIR_LED_BLK_DUR_128M, ++ AIR_LED_BLK_DUR_256M, ++ AIR_LED_BLK_DUR_512M, ++ AIR_LED_BLK_DUR_1024M, ++ AIR_LED_BLK_DUR_LAST ++}; ++ ++enum { ++ AIR_ACTIVE_LOW, ++ AIR_ACTIVE_HIGH, ++}; ++ ++enum { ++ AIR_LED_MODE_DISABLE, ++ AIR_LED_MODE_USER_DEFINE, ++ AIR_LED_MODE_LAST ++}; ++ ++#endif /* End of __EN8811H_MD32_H */ ++ +--- a/drivers/net/eth-phy-uclass.c ++++ b/drivers/net/eth-phy-uclass.c +@@ -155,7 +155,7 @@ static int eth_phy_of_to_plat(struct ude + return 0; + } + +-static void eth_phy_reset(struct udevice *dev, int value) ++void eth_phy_reset(struct udevice *dev, int value) + { + struct eth_phy_device_priv *uc_priv = dev_get_uclass_priv(dev); + u32 delay; +--- a/include/eth_phy.h ++++ b/include/eth_phy.h +@@ -14,5 +14,6 @@ int eth_phy_binds_nodes(struct udevice * + int eth_phy_set_mdio_bus(struct udevice *eth_dev, struct mii_dev *mdio_bus); + struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev); + int eth_phy_get_addr(struct udevice *dev); ++void eth_phy_reset(struct udevice *dev, int value); + + #endif diff --git a/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch b/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch index ae7623086e4475..28175e02e87fd0 100644 --- a/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch +++ b/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch @@ -1,6 +1,6 @@ --- a/cmd/bootm.c +++ b/cmd/bootm.c -@@ -259,6 +259,67 @@ U_BOOT_CMD( +@@ -245,6 +245,67 @@ U_BOOT_CMD( /* iminfo - print header info for a requested image */ /*******************************************************************/ #if defined(CONFIG_CMD_IMI) @@ -120,7 +120,7 @@ int arch, int ph_type, int bootstage_id, --- a/include/image.h +++ b/include/image.h -@@ -1047,6 +1047,7 @@ int fit_parse_subimage(const char *spec, +@@ -1049,6 +1049,7 @@ int fit_parse_subimage(const char *spec, ulong *addr, const char **image_name); int fit_get_subimage_count(const void *fit, int images_noffset); diff --git a/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch b/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch index d91b9904cbd0e9..7bf87ef7b5aebf 100644 --- a/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch +++ b/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch @@ -1,6 +1,6 @@ --- a/cmd/Kconfig +++ b/cmd/Kconfig -@@ -602,6 +602,12 @@ config CMD_ENV_EXISTS +@@ -622,6 +622,12 @@ config CMD_ENV_EXISTS Check if a variable is defined in the environment for use in shell scripting. @@ -15,7 +15,7 @@ help --- a/cmd/nvedit.c +++ b/cmd/nvedit.c -@@ -408,6 +408,60 @@ int do_env_ask(struct cmd_tbl *cmdtp, in +@@ -385,6 +385,60 @@ int do_env_ask(struct cmd_tbl *cmdtp, in } #endif @@ -76,7 +76,7 @@ #if defined(CONFIG_CMD_ENV_CALLBACK) static int print_static_binding(const char *var_name, const char *callback_name, void *priv) -@@ -1228,6 +1282,9 @@ static struct cmd_tbl cmd_env_sub[] = { +@@ -1201,6 +1255,9 @@ static struct cmd_tbl cmd_env_sub[] = { U_BOOT_CMD_MKENT(load, 1, 0, do_env_load, "", ""), #endif U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""), @@ -86,7 +86,7 @@ #if defined(CONFIG_CMD_RUN) U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""), #endif -@@ -1319,6 +1376,9 @@ static char env_help_text[] = +@@ -1284,6 +1341,9 @@ U_BOOT_LONGHELP(env, #if defined(CONFIG_CMD_NVEDIT_EFI) "env print -e [-guid guid] [-n] [name ...] - print UEFI environment\n" #endif @@ -96,7 +96,7 @@ #if defined(CONFIG_CMD_RUN) "env run var [...] - run commands in an environment variable\n" #endif -@@ -1428,6 +1488,17 @@ U_BOOT_CMD( +@@ -1392,6 +1452,17 @@ U_BOOT_CMD( ); #endif diff --git a/package/boot/uboot-mediatek/patches/230-cmd-add-pstore-check.patch b/package/boot/uboot-mediatek/patches/230-cmd-add-pstore-check.patch index d0abcb1acc2b22..48556937bd8bb7 100644 --- a/package/boot/uboot-mediatek/patches/230-cmd-add-pstore-check.patch +++ b/package/boot/uboot-mediatek/patches/230-cmd-add-pstore-check.patch @@ -67,7 +67,7 @@ U_BOOT_CMD_MKENT(display, 3, 0, pstore_display, "", ""), U_BOOT_CMD_MKENT(save, 4, 0, pstore_save, "", ""), }; -@@ -560,6 +613,8 @@ U_BOOT_CMD(pstore, 10, 0, do_pstore, +@@ -566,6 +619,8 @@ U_BOOT_CMD(pstore, 10, 0, do_pstore, " 'pmsg-size' is the size of the user space logs record.\n" " 'ecc-size' enables/disables ECC support and specifies ECC buffer size in\n" " bytes (0 disables it, 1 is a special value, means 16 bytes ECC).\n" diff --git a/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch b/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch new file mode 100644 index 00000000000000..fd5fdd814b8c35 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/250-fix-mmc-erase-timeout.patch @@ -0,0 +1,11 @@ +--- a/drivers/mmc/mmc_write.c ++++ b/drivers/mmc/mmc_write.c +@@ -80,7 +80,7 @@ ulong mmc_berase(struct blk_desc *block_ + u32 start_rem, blkcnt_rem, erase_args = 0; + struct mmc *mmc = find_mmc_device(dev_num); + lbaint_t blk = 0, blk_r = 0; +- int timeout_ms = 1000; ++ int timeout_ms = blkcnt; + + if (!mmc) + return -1; diff --git a/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch new file mode 100644 index 00000000000000..86c48badda9706 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch @@ -0,0 +1,46 @@ +--- a/board/mediatek/mt7623/mt7623_rfb.c ++++ b/board/mediatek/mt7623/mt7623_rfb.c +@@ -5,6 +5,7 @@ + + #include + #include ++#include + #include + + DECLARE_GLOBAL_DATA_PTR; +@@ -22,8 +23,9 @@ int mmc_get_boot_dev(void) + { + int g_mmc_devid = -1; + char *uflag = (char *)0x81DFFFF0; ++ struct blk_desc *desc; + +- if (!find_mmc_device(1)) ++ if (blk_get_device_by_str("mmc", "1", &desc) < 0) + return 0; + + if (strncmp(uflag,"eMMC",4)==0) { +@@ -38,6 +40,23 @@ int mmc_get_boot_dev(void) + + int mmc_get_env_dev(void) + { +- return mmc_get_boot_dev(); ++ struct udevice *dev; ++ const char *mmcdev; ++ ++ switch (mmc_get_boot_dev()) { ++ case 0: ++ mmcdev = "mmc@11230000"; ++ break; ++ case 1: ++ mmcdev = "mmc@11240000"; ++ break; ++ default: ++ return -1; ++ } ++ ++ if (uclass_get_device_by_name(UCLASS_MMC, mmcdev, &dev)) ++ return -1; ++ ++ return dev_seq(dev); + } + #endif diff --git a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch index 928dfe8428a3de..b8d89058a2e93a 100644 --- a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7623/mt7623_rfb.c +++ b/board/mediatek/mt7623/mt7623_rfb.c -@@ -4,8 +4,17 @@ +@@ -4,9 +4,18 @@ */ #include @@ -9,6 +9,7 @@ +#include +#include #include + #include #include +#include + @@ -18,8 +19,8 @@ DECLARE_GLOBAL_DATA_PTR; -@@ -41,3 +50,25 @@ int mmc_get_env_dev(void) - return mmc_get_boot_dev(); +@@ -60,3 +69,25 @@ int mmc_get_env_dev(void) + return dev_seq(dev); } #endif + diff --git a/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch new file mode 100644 index 00000000000000..28d7e0a3f6e5cb --- /dev/null +++ b/package/boot/uboot-mediatek/patches/310-mt7988-select-rootdisk.patch @@ -0,0 +1,67 @@ +--- a/board/mediatek/mt7988/mt7988_rfb.c ++++ b/board/mediatek/mt7988/mt7988_rfb.c +@@ -11,7 +11,9 @@ + #include + #include + #include ++#include + #include ++#include + + #ifndef CONFIG_RESET_BUTTON_LABEL + #define CONFIG_RESET_BUTTON_LABEL "reset" +@@ -44,3 +46,54 @@ int board_late_init(void) + env_relocate(); + return 0; + } ++ ++#define MT7988_BOOT_NOR 0 ++#define MT7988_BOOT_SPIM_NAND 1 ++#define MT7988_BOOT_EMMC 2 ++#define MT7988_BOOT_SNFI_NAND 3 ++ ++int ft_system_setup(void *blob, struct bd_info *bd) ++{ ++ const u32 *media_handle_p; ++ int chosen, len, ret; ++ const char *media; ++ u32 media_handle; ++ ++ switch ((readl(0x1001f6f0) & 0xc00) >> 10) { ++ case MT7988_BOOT_NOR: ++ media = "rootdisk-nor"; ++ break ++ ;; ++ case MT7988_BOOT_SPIM_NAND: ++ media = "rootdisk-spim-nand"; ++ break ++ ;; ++ case MT7988_BOOT_EMMC: ++ media = "rootdisk-emmc"; ++ break ++ ;; ++ case MT7988_BOOT_SNFI_NAND: ++ media = "rootdisk-sd"; ++ break ++ ;; ++ } ++ ++ chosen = fdt_path_offset(blob, "/chosen"); ++ if (chosen <= 0) ++ return 0; ++ ++ media_handle_p = fdt_getprop(blob, chosen, media, &len); ++ if (media_handle_p <= 0 || len != 4) ++ return 0; ++ ++ media_handle = *media_handle_p; ++ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle)); ++ if (ret) { ++ printf("cannot set media phandle %s as rootdisk /chosen node\n", media); ++ return ret; ++ } ++ ++ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle)); ++ ++ return 0; ++} diff --git a/package/boot/uboot-mediatek/patches/311-mt7986-select-roodisk.patch b/package/boot/uboot-mediatek/patches/311-mt7986-select-roodisk.patch new file mode 100644 index 00000000000000..33121627655d4d --- /dev/null +++ b/package/boot/uboot-mediatek/patches/311-mt7986-select-roodisk.patch @@ -0,0 +1,67 @@ +--- a/board/mediatek/mt7986/mt7986_rfb.c ++++ b/board/mediatek/mt7986/mt7986_rfb.c +@@ -11,7 +11,9 @@ + #include + #include + #include ++#include + #include ++#include + + #ifndef CONFIG_RESET_BUTTON_LABEL + #define CONFIG_RESET_BUTTON_LABEL "reset" +@@ -83,3 +85,54 @@ int board_nmbm_init(void) + + return 0; + } ++ ++#define MT7986_BOOT_NOR 0 ++#define MT7986_BOOT_SPIM_NAND 1 ++#define MT7986_BOOT_EMMC 2 ++#define MT7986_BOOT_SNFI_NAND 3 ++ ++int ft_system_setup(void *blob, struct bd_info *bd) ++{ ++ const u32 *media_handle_p; ++ int chosen, len, ret; ++ const char *media; ++ u32 media_handle; ++ ++ switch ((readl(0x1001f6f0) & 0x300) >> 8) { ++ case MT7986_BOOT_NOR: ++ media = "rootdisk-nor"; ++ break ++ ;; ++ case MT7986_BOOT_SPIM_NAND: ++ media = "rootdisk-spim-nand"; ++ break ++ ;; ++ case MT7986_BOOT_EMMC: ++ media = "rootdisk-emmc"; ++ break ++ ;; ++ case MT7986_BOOT_SNFI_NAND: ++ media = "rootdisk-sd"; ++ break ++ ;; ++ } ++ ++ chosen = fdt_path_offset(blob, "/chosen"); ++ if (chosen <= 0) ++ return 0; ++ ++ media_handle_p = fdt_getprop(blob, chosen, media, &len); ++ if (media_handle_p <= 0 || len != 4) ++ return 0; ++ ++ media_handle = *media_handle_p; ++ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle)); ++ if (ret) { ++ printf("cannot set media phandle %s as rootdisk /chosen node\n", media); ++ return ret; ++ } ++ ++ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle)); ++ ++ return 0; ++} diff --git a/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch new file mode 100644 index 00000000000000..70cbf6b46300e2 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/312-mt7622-select-rootdisk.patch @@ -0,0 +1,141 @@ +--- a/board/mediatek/mt7622/mt7622_rfb.c ++++ b/board/mediatek/mt7622/mt7622_rfb.c +@@ -11,7 +11,9 @@ + #include + #include + #include ++#include + #include ++#include + + #ifndef CONFIG_RESET_BUTTON_LABEL + #define CONFIG_RESET_BUTTON_LABEL "reset" +@@ -22,10 +24,43 @@ + #include + #include + ++#define MT7622_TOPRGUSTRAP_PAR 0x10212060 ++#define MT7622_BOOT_SEQ_MASK 0x18 ++#define MT7622_BOOT_SEQ_SHIFT 3 ++#define MT7622_BOOT_SEQ_NOR_EMMC_SDXC 0x0 ++#define MT7622_BOOT_SEQ_SPI_NAND_EMMC_SDXC 0x1 ++#define MT7622_BOOT_SEQ_NAND_EMMC_SDXC 0x2 ++#define MT7622_BOOT_SEQ_SDXC_EMMC_NAND 0x3 ++ ++#define MT7622_GPIO_MODE0 0x10211300 ++#define MT7622_GPIO_NAND_MODE_MASK 0x00f00000 ++#define MT7622_GPIO_NAND_MODE_SHIFT 20 ++#define MT7622_GPIO_NAND_MODE_EMMC 0x2 ++#define MT7622_GPIO_RGMII_MODE_MASK 0x0000f000 ++#define MT7622_GPIO_RGMII_MODE_SHIFT 12 ++#define MT7622_GPIO_RGMII_MODE_SDCX 0x2 ++#define MT7622_GPIO_SPI_MODE_MASK 0x00000f00 ++#define MT7622_GPIO_SPI_MODE_SHIFT 8 ++#define MT7622_GPIO_SPI_MODE_NAND 0x2 ++ ++#define MT7622_MSDC_INT 0x1124000C ++#define MT7622_MSDC_INT_BD_CS_ERR 0x200 ++ + DECLARE_GLOBAL_DATA_PTR; + ++static int gpio_mode0; ++static int msdc_int; ++ + int board_init(void) + { ++ /* ++ * Save content of GPIO_MODE0 as left behind by the BootROM. ++ * Also grab MSDC1 INT status to see if BootROM has been reading ++ * from SD card. ++ * Together this will allow to infer the device used for booting. ++ */ ++ gpio_mode0 = readl(MT7622_GPIO_MODE0); ++ msdc_int = readl(MT7622_MSDC_INT); + return 0; + } + +@@ -83,3 +118,84 @@ int board_nmbm_init(void) + + return 0; + } ++ ++int ft_system_setup(void *blob, struct bd_info *bd) ++{ ++ bool pinctrl_set_mmc = false; ++ bool pinctrl_set_snfi = false; ++ bool pinctrl_set_emmc = false; ++ bool msdc_bd_cs_err = false; ++ ++ const u32 *media_handle_p; ++ int chosen, len, ret; ++ const char *media; ++ u32 media_handle, strap; ++ ++ if ((gpio_mode0 & MT7622_GPIO_RGMII_MODE_MASK) >> ++ MT7622_GPIO_RGMII_MODE_SHIFT == MT7622_GPIO_RGMII_MODE_SDCX) ++ pinctrl_set_mmc = true; ++ ++ if ((gpio_mode0 & MT7622_GPIO_SPI_MODE_MASK) >> ++ MT7622_GPIO_SPI_MODE_SHIFT == MT7622_GPIO_SPI_MODE_NAND) ++ pinctrl_set_snfi = true; ++ ++ if ((gpio_mode0 & MT7622_GPIO_NAND_MODE_MASK) >> ++ MT7622_GPIO_NAND_MODE_SHIFT == MT7622_GPIO_NAND_MODE_EMMC) ++ pinctrl_set_emmc = true; ++ ++ if (msdc_int & MT7622_MSDC_INT_BD_CS_ERR) ++ msdc_bd_cs_err = true; ++ ++ strap = readl(MT7622_TOPRGUSTRAP_PAR); ++ strap &= MT7622_BOOT_SEQ_MASK; ++ strap >>= MT7622_BOOT_SEQ_SHIFT; ++ switch (strap) { ++ case MT7622_BOOT_SEQ_NOR_EMMC_SDXC: ++ if (!pinctrl_set_emmc) ++ media = "rootdisk-nor"; ++ else if (pinctrl_set_mmc) ++ media = "rootdisk-emmc"; ++ else ++ media = "rootdisk-sd"; ++ break ++ ;; ++ case MT7622_BOOT_SEQ_SPI_NAND_EMMC_SDXC: ++ if (pinctrl_set_snfi) ++ media = "rootdisk-snfi"; ++ else if (pinctrl_set_emmc) ++ media = "rootdisk-emmc"; ++ else ++ media = "rootdisk-sd"; ++ break ++ ;; ++ case MT7622_BOOT_SEQ_NAND_EMMC_SDXC: ++ case MT7622_BOOT_SEQ_SDXC_EMMC_NAND: ++ if (!pinctrl_set_emmc && pinctrl_set_mmc) ++ media = "rootdisk-nand"; ++ else if (pinctrl_set_emmc) ++ media = "rootdisk-emmc"; ++ else ++ media = "rootdisk-sd"; ++ break ++ ;; ++ } ++ ++ chosen = fdt_path_offset(blob, "/chosen"); ++ if (chosen <= 0) ++ return 0; ++ ++ media_handle_p = fdt_getprop(blob, chosen, media, &len); ++ if (media_handle_p <= 0 || len != 4) ++ return 0; ++ ++ media_handle = *media_handle_p; ++ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle)); ++ if (ret) { ++ printf("cannot set media phandle %s as rootdisk /chosen node\n", media); ++ return ret; ++ } ++ ++ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle)); ++ ++ return 0; ++} diff --git a/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch new file mode 100644 index 00000000000000..0089307bbd6b84 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch @@ -0,0 +1,46 @@ +--- a/board/mediatek/mt7623/mt7623_rfb.c ++++ b/board/mediatek/mt7623/mt7623_rfb.c +@@ -91,3 +91,43 @@ int board_late_init(void) + env_relocate(); + return 0; + } ++ ++int ft_system_setup(void *blob, struct bd_info *bd) ++{ ++ const u32 *media_handle_p; ++ int chosen, len, ret; ++ const char *media; ++ u32 media_handle; ++ ++#ifdef CONFIG_MMC ++ switch (mmc_get_boot_dev()) { ++ case 0: ++ media = "rootdisk-emmc"; ++ break ++ ;; ++ case 1: ++ media = "rootdisk-sd"; ++ break ++ ;; ++ } ++ ++ chosen = fdt_path_offset(blob, "/chosen"); ++ if (chosen <= 0) ++ return 0; ++ ++ media_handle_p = fdt_getprop(blob, chosen, media, &len); ++ if (media_handle_p <= 0 || len != 4) ++ return 0; ++ ++ media_handle = *media_handle_p; ++ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle)); ++ if (ret) { ++ printf("cannot set media phandle %s as rootdisk /chosen node\n", media); ++ return ret; ++ } ++ ++ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle)); ++#endif ++ ++ return 0; ++} diff --git a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch index 7ebe5c0fc7a6d9..ab3424e6b591ba 100644 --- a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch +++ b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch @@ -1,6 +1,6 @@ --- a/configs/mt7623n_bpir2_defconfig +++ b/configs/mt7623n_bpir2_defconfig -@@ -7,35 +7,105 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 +@@ -7,34 +7,106 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x81ffff10 @@ -8,19 +8,17 @@ +CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_DEFAULT_DEVICE_TREE="mt7623n-bananapi-bpi-r2" --CONFIG_SYS_PROMPT="U-Boot> " -+CONFIG_USE_DEFAULT_ENV_FILE=y -+CONFIG_SYS_PROMPT="MT7623> " CONFIG_TARGET_MT7623=y CONFIG_SYS_LOAD_ADDR=0x84000000 CONFIG_FIT=y --CONFIG_FIT_VERBOSE=y + CONFIG_FIT_VERBOSE=y +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y +CONFIG_LED=y +CONFIG_LED_BLINK=y +CONFIG_LED_GPIO=y +CONFIG_LOGLEVEL=7 +CONFIG_LOG=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_AUTOBOOT_KEYED=y +CONFIG_AUTOBOOT_MENU_SHOW=y +CONFIG_BOARD_LATE_INIT=y @@ -38,6 +36,9 @@ +CONFIG_CFB_CONSOLE_ANSI=y +CONFIG_CMD_ENV_FLAGS=y # CONFIG_DISPLAY_BOARDINFO is not set +-CONFIG_SYS_PROMPT="U-Boot> " ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_SYS_PROMPT="MT7623> " CONFIG_SYS_MAXARGS=8 CONFIG_SYS_PBSIZE=1049 CONFIG_SYS_BOOTM_LEN=0x4000000 @@ -70,7 +71,6 @@ CONFIG_CMD_MMC=y CONFIG_CMD_READ=y -# CONFIG_CMD_SETEXPR is not set - # CONFIG_CMD_NFS is not set +CONFIG_CMD_SF_TEST=y +CONFIG_CMD_PING=y +CONFIG_CMD_PXE=y @@ -111,7 +111,7 @@ CONFIG_USE_IPADDR=y CONFIG_IPADDR="192.168.1.1" CONFIG_USE_SERVERIP=y -@@ -47,6 +117,12 @@ CONFIG_CLK=y +@@ -46,6 +118,12 @@ CONFIG_CLK=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS400_SUPPORT=y CONFIG_MMC_MTK=y @@ -124,7 +124,7 @@ CONFIG_PHY_FIXED=y CONFIG_MEDIATEK_ETH=y CONFIG_PINCTRL=y -@@ -56,10 +132,13 @@ CONFIG_POWER_DOMAIN=y +@@ -55,10 +133,13 @@ CONFIG_POWER_DOMAIN=y CONFIG_MTK_POWER_DOMAIN=y CONFIG_DM_SERIAL=y CONFIG_MTK_SERIAL=y @@ -140,7 +140,7 @@ # CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set --- /dev/null +++ b/bananapi_bpi-r2_env -@@ -0,0 +1,70 @@ +@@ -0,0 +1,69 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x88000000 @@ -193,14 +193,13 @@ +sdmmc_write_recovery=iminfo $fileaddr && mmc dev 1 && part start mmc 1 $part_recovery part_addr && part size mmc 1 $part_recovery part_size && run mmc_write_vol +_checkbootedfrom=setenv _checkbootedfrom ; if itest.l *81dffff0 == 434d4d65 ; then setenv bootedfrom eMMC ; else setenv bootedfrom SD ; fi +_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv -+_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootdev _update_bootcmd _update_bootcmd2 _init_env boot_first ++_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootcmd _update_bootcmd2 _init_env boot_first +_set_bootcmd_sdmmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run sdmmc_read_production && bootm $loadaddr ; led $bootled_pwr off" +_set_bootcmd_emmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr ; led $bootled_pwr off" +_update_bootcmd=setenv _update_bootcmd ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd_sdmmc ; else run _set_bootcmd_emmc ; fi ; setenv _set_bootcmd_sdmmc ; setenv _set_bootcmd_emmc +_set_bootcmd2_sdmmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run sdmmc_read_recovery && bootm $loadaddr ; led $bootled_rec off" +_set_bootcmd2_emmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr ; led $bootled_rec off" +_update_bootcmd2=setenv _update_bootcmd2 ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd2_sdmmc ; else run _set_bootcmd2_emmc ; fi ; setenv _set_bootcmd2_sdmmc ; setenv _set_bootcmd2_emmc -+_update_bootdev=setenv _update_bootdev ; if test "$bootedfrom" = "SD" ; then setenv bootargs "$console root=/dev/mmcblk1p65" ; else setenv bootargs "$console root=/dev/mmcblk0p65" ; fi +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title [$bootedfrom] $ver" ; run _set_bm2 +_set_bm2=setenv _set_bm2 ; setenv bootmenu_2 "Boot production system from $bootedfrom.=run boot_production ; run bootmenu_confirm_return" ; run _set_bm3 diff --git a/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch b/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch index 453456c94f92b2..6528b165f522d8 100644 --- a/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch +++ b/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch @@ -1,6 +1,6 @@ --- a/configs/mt7623a_unielec_u7623_02_defconfig +++ b/configs/mt7623a_unielec_u7623_02_defconfig -@@ -7,34 +7,110 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 +@@ -7,33 +7,109 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x81ffff10 @@ -8,13 +8,10 @@ +CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_DEFAULT_DEVICE_TREE="mt7623a-unielec-u7623-02-emmc" --CONFIG_SYS_PROMPT="U-Boot> " -+CONFIG_USE_DEFAULT_ENV_FILE=y -+CONFIG_SYS_PROMPT="MT7623> " CONFIG_TARGET_MT7623=y CONFIG_SYS_LOAD_ADDR=0x84000000 CONFIG_FIT=y --CONFIG_FIT_VERBOSE=y + CONFIG_FIT_VERBOSE=y +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y +CONFIG_LED=y +CONFIG_LED_BLINK=y @@ -38,6 +35,9 @@ +CONFIG_CFB_CONSOLE_ANSI=y +CONFIG_CMD_ENV_FLAGS=y # CONFIG_DISPLAY_BOARDINFO is not set +-CONFIG_SYS_PROMPT="U-Boot> " ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_SYS_PROMPT="MT7623> " CONFIG_SYS_MAXARGS=8 CONFIG_SYS_PBSIZE=1049 CONFIG_SYS_BOOTM_LEN=0x4000000 @@ -71,7 +71,6 @@ CONFIG_CMD_MMC=y CONFIG_CMD_READ=y -# CONFIG_CMD_SETEXPR is not set - # CONFIG_CMD_NFS is not set +CONFIG_CMD_SF_TEST=y +CONFIG_CMD_PING=y +CONFIG_CMD_PXE=y @@ -110,13 +109,12 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SYS_MMC_ENV_DEV=0 +CONFIG_ENV_OVERWRITE=y -+CONFIG_ENV_IS_IN_MMC=y CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_NETCONSOLE=y CONFIG_USE_IPADDR=y CONFIG_IPADDR="192.168.1.1" CONFIG_USE_SERVERIP=y -@@ -46,6 +122,11 @@ CONFIG_CLK=y +@@ -45,6 +121,11 @@ CONFIG_CLK=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS400_SUPPORT=y CONFIG_MMC_MTK=y @@ -128,7 +126,7 @@ CONFIG_PHY_FIXED=y CONFIG_MEDIATEK_ETH=y CONFIG_PINCTRL=y -@@ -55,9 +136,12 @@ CONFIG_POWER_DOMAIN=y +@@ -54,9 +135,12 @@ CONFIG_POWER_DOMAIN=y CONFIG_MTK_POWER_DOMAIN=y CONFIG_DM_SERIAL=y CONFIG_MTK_SERIAL=y diff --git a/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch b/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch index c9da03c725400d..2ec57708067ba6 100644 --- a/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch +++ b/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch @@ -9,7 +9,7 @@ ethernet0 = ð }; -@@ -208,17 +208,11 @@ +@@ -208,16 +208,27 @@ }; }; @@ -22,12 +22,26 @@ + pinctrl-0 = <&snfi_pins>; + quad-spi; status = "okay"; -- + - spi-flash@0{ - compatible = "jedec,spi-nor"; - reg = <0>; - bootph-all; -- }; ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "bl2"; ++ reg = <0x0 0x80000>; ++ }; ++ ++ partition@80000 { ++ label = "ubi"; ++ reg = <0x80000 0x7f80000>; ++ compatible = "linux,ubi"; ++ }; + }; }; - &uart0 { diff --git a/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch b/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch index f3d9499e171db0..04411d79bcd054 100644 --- a/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch +++ b/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch @@ -17,6 +17,7 @@ +CONFIG_DEBUG_UART_CLOCK=25000000 +CONFIG_DEFAULT_DEVICE_TREE="mt7622-bananapi-bpi-r64" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART=y +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r64-sdmmc_env" +CONFIG_NET_RANDOM_ETHADDR=y @@ -126,7 +127,6 @@ +CONFIG_PCI=y +CONFIG_MTD=y +CONFIG_MTD_UBI_FASTMAP=y -+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-nand0:512k(bl2),2048k(fip),-(ubi)" +CONFIG_DM_PCI=y +CONFIG_PCIE_MEDIATEK=y +CONFIG_PINCTRL=y @@ -167,11 +167,11 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/bananapi_bpi-r64-sdmmc_env -@@ -0,0 +1,82 @@ +@@ -0,0 +1,81 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x48000000 -+bootargs=root=/dev/mmcblk1p65 ++bootargs=root=/dev/fit0 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_sdmmc ; fi +bootconf=config-1#mt7622-bananapi-bpi-r64-pcie1 +bootconf_pcie=config-1#mt7622-bananapi-bpi-r64-pcie1 @@ -210,7 +210,6 @@ +boot_ubi=ubi part ubi && setenv bootargs && run boot_ubi_production ; run boot_ubi_recovery +boot_ubi_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr ; led $bootled_pwr off +boot_ubi_recovery=led $bootled_rec on ; run ubi_read_recovery ; bootm $loadaddr#$bootconf ; ubi remove recovery ; led $bootled_rec off -+check_ubi=ubi part ubi || run ubi_format +emmc_init=run emmc_init_bl && run emmc_init_openwrt ; env default bootcmd ; saveenv ; saveenv +emmc_init_bl=run sdmmc_read_emmc_bl2 && run emmc_write_bl2 && run sdmmc_read_emmc_hdr && run emmc_write_hdr && run sdmmc_read_emmc_fip && run emmc_write_fip +emmc_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run emmc_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run emmc_write_production @@ -220,7 +219,7 @@ +emmc_write_production=mmc dev 0 && part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol +emmc_write_recovery=mmc dev 0 && part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol +mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size -+mmc_read_vol=mmc read $loadaddr $part_addr 0x8 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200 ++mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200 +part_default=production +part_recovery=recovery +reset_factory=eraseenv && reset @@ -233,26 +232,26 @@ +sdmmc_read_snand_fip=mmc dev 1 && part start mmc 1 install part_addr && setexpr offset $part_addr + 0x2400 && mmc read $loadaddr $offset 0x1000 +sdmmc_write_production=mmc dev 1 && part start mmc 1 $part_default part_addr && part size mmc 1 $part_default part_size && run mmc_write_vol +sdmmc_write_recovery=mmc dev 1 && part start mmc 1 $part_recovery part_addr && part size mmc 1 $part_recovery part_size && run mmc_write_vol -+snand_write_fip=mtd erase fip && mtd write fip $loadaddr -+snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr -+ubi_create_env=ubi create ubootenv 0x100000 dynamic 0 ; ubi create ubootenv2 0x100000 dynamic 1 ; ubi create fit 0x100000 dynamic 2 ; ubi create recovery 0x100000 dynamic 3 -+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset -+ubi_init=run ubi_init_bl && ubi detach && mtd erase ubi && ubi part ubi && run ubi_create_env && run ubi_init_openwrt ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x20000 && mtd write bl2 $loadaddr 0x20000 0x20000 && mtd write bl2 $loadaddr 0x40000 0x20000 && mtd write bl2 $loadaddr 0x60000 0x20000 ++ubi_create_env=ubi create ubootenv 0x1f000 dynamic ; ubi create ubootenv2 0x1f000 dynamic ++ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ++ubi_init=run ubi_format && run ubi_init_bl && run ubi_create_env && run ubi_init_openwrt +ubi_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run ubi_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run ubi_write_production -+ubi_init_bl=run sdmmc_read_snand_bl2 && run snand_write_bl2 && run sdmmc_read_snand_fip && run snand_write_fip ++ubi_init_bl=run sdmmc_read_snand_bl2 && run snand_write_bl2 && run sdmmc_read_snand_fip && run ubi_write_fip +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data -+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize -+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic 3 && ubi write $loadaddr recovery $filesize ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize +_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" --- /dev/null +++ b/configs/mt7622_bananapi_bpi-r64-emmc_defconfig -@@ -0,0 +1,151 @@ +@@ -0,0 +1,152 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -269,6 +268,7 @@ +CONFIG_DEBUG_UART_CLOCK=25000000 +CONFIG_DEFAULT_DEVICE_TREE="mt7622-bananapi-bpi-r64" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART=y +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r64-emmc_env" +CONFIG_NET_RANDOM_ETHADDR=y @@ -411,7 +411,7 @@ +serverip=192.168.1.254 +loadaddr=0x48000000 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi -+bootargs=root=/dev/mmcblk0p65 ++bootargs=root=/dev/fit0 +bootconf=config-1#mt7622-bananapi-bpi-r64-pcie1 +bootconf_pcie=config-1#mt7622-bananapi-bpi-r64-pcie1 +bootconf_sata=config-1#mt7622-bananapi-bpi-r64-sata @@ -455,7 +455,7 @@ +emmc_read_production=mmc dev 0 && part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_read_vol +emmc_read_recovery=mmc dev 0 && part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_read_vol +mmc_write_vol=imszb $fileaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $fileaddr 0x$part_addr 0x$image_size -+mmc_read_vol=mmc read $loadaddr $part_addr 0x8 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size ++mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size +part_default=production +part_recovery=recovery +reset_factory=eraseenv && reset @@ -481,6 +481,7 @@ +CONFIG_DEBUG_UART_CLOCK=25000000 +CONFIG_DEFAULT_DEVICE_TREE="mt7622-bananapi-bpi-r64" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART=y +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r64-snand_env" +CONFIG_DISTRO_DEFAULTS=y @@ -574,7 +575,6 @@ +CONFIG_PCI=y +CONFIG_MTD=y +CONFIG_MTD_UBI_FASTMAP=y -+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-nand0:512k(bl2),2048k(fip),-(ubi)" +CONFIG_DM_PCI=y +CONFIG_PCIE_MEDIATEK=y +CONFIG_PINCTRL=y @@ -613,11 +613,11 @@ +CONFIG_SERVERIP="192.168.1.3" --- /dev/null +++ b/bananapi_bpi-r64-snand_env -@@ -0,0 +1,57 @@ +@@ -0,0 +1,56 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x48000000 -+bootargs=root=/dev/ubiblock0_2p1 ++bootargs=ubi.block=0,fit root=/dev/fit0 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi +bootconf=config-1#mt7622-bananapi-bpi-r64-pcie1 +bootconf_pcie=config-1#mt7622-bananapi-bpi-r64-pcie1 @@ -652,22 +652,21 @@ +boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done +boot_tftp_production=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && ubi part ubi && run ubi_write_production ubi_prepare_rootfs ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp_recovery=tftpboot $loadaddr $bootfile && iminfo $loadaddr && ubi part ubi && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi -+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run boot_write_bl2 -+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run boot_write_fip ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip +boot_ubi=ubi part ubi && run boot_production ; run boot_recovery -+boot_write_bl2=mtd erase bl2 && mtd write spi-nand0 $loadaddr 0x0 0x20000 && mtd write spi-nand0 $loadaddr 0x20000 0x20000 && mtd write spi-nand0 $loadaddr 0x40000 0x20000 && mtd write spi-nand0 $loadaddr 0x60000 0x20000 -+boot_write_fip=mtd erase fip && mtd write fip $loadaddr ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x20000 && mtd write bl2 $loadaddr 0x20000 0x20000 && mtd write bl2 $loadaddr 0x40000 0x20000 && mtd write bl2 $loadaddr 0x60000 0x20000 +check_ubi=ubi part ubi || run ubi_format -+reset_factory=mw $loadaddr 0x0 0x100000 ; ubi part ubi ; ubi write $loadaddr ubootenv 0x100000 ; ubi write $loadaddr ubootenv2 0x100000 ; ubi remove rootfs_data -+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset ++reset_factory=mw $loadaddr 0x0 0x1f000 ; ubi part ubi ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 +ubi_write_production=ubi check fit && env exists replacevol && ubi remove fit ; if ubi check fit ; then else run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize ; fi +ubi_write_recovery=ubi check recovery && env exists replacevol && ubi remove recovery ; if ubi check recovery ; then else run ubi_remove_rootfs ; ubi create recovery $filesize dynamic 3 && ubi write $loadaddr recovery $filesize ; fi -+_create_env=ubi create ubootenv 0x100000 dynamic 0 ; ubi create ubootenv2 0x100000 dynamic 1 ; ubi create fit 0x100000 dynamic 2 ; ubi create recovery 0x100000 dynamic 3 -+_init_env=setenv _init_env ; if ubi check ubootenv && ubi check ubootenv2 ; then else run _create_env ; fi ; setenv _create_env ; saveenv || run ubi_format ; saveenv || run ubi_format -+_firstboot=setenv _firstboot ; run _switch_to_menu ; run check_ubi ; run _init_env ; run boot_first ++_create_env=ubi create ubootenv 0x1f000 dynamic ; ubi create ubootenv2 0x1f000 dynamic ++_init_env=setenv _init_env ; if ubi check ubootenv && ubi check ubootenv2 ; then else run _create_env ; fi ; setenv _create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" diff --git a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch index 363509efc1b344..ca8fb32bead132 100644 --- a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch +++ b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/configs/mt7622_linksys_e8450_defconfig -@@ -0,0 +1,141 @@ +@@ -0,0 +1,140 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -17,7 +17,6 @@ +CONFIG_DEBUG_UART_CLOCK=25000000 +CONFIG_DEFAULT_DEVICE_TREE="mt7622-linksys-e8450-ubi" +CONFIG_DEBUG_UART=y -+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-nand0:512k(bl2),1280k(fip),1024k(factory),256k(reserved),-(ubi)" +CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_AUTOBOOT_KEYED=y +CONFIG_BOOTDELAY=30 @@ -144,7 +143,7 @@ +CONFIG_USB_STORAGE=y --- /dev/null +++ b/arch/arm/dts/mt7622-linksys-e8450-ubi.dts -@@ -0,0 +1,197 @@ +@@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. @@ -307,6 +306,23 @@ + pinctrl-0 = <&snfi_pins>; + status = "okay"; + quad-spi; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "bl2"; ++ reg = <0x0 0x80000>; ++ }; ++ ++ partition@80000 { ++ label = "ubi"; ++ reg = <0x80000 0x7f80000>; ++ compatible = "linux,ubi"; ++ }; ++ }; +}; + +&uart0 { @@ -344,7 +360,7 @@ +}; --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1305,6 +1305,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1422,6 +1422,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7622-rfb.dtb \ mt7623a-unielec-u7623-02-emmc.dtb \ mt7622-bananapi-bpi-r64.dtb \ @@ -354,8 +370,8 @@ mt7981-rfb.dtb \ --- /dev/null +++ b/linksys_e8450_env -@@ -0,0 +1,57 @@ -+ethaddr_factory=mtd read spi-nand0 0x40080000 0x220000 0x20000 && env readmem -b ethaddr 0x4009fff4 0x6 ; setenv ethaddr_factory +@@ -0,0 +1,55 @@ ++ethaddr_factory=ubi read 0x40080000 factory && env readmem -b ethaddr 0x400ffff4 0x6 ; setenv ethaddr_factory +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x48000000 @@ -387,28 +403,26 @@ +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever +boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off +boot_recovery=led $bootled_rec on ; run ubi_read_recovery ; bootm $loadaddr#$bootconf ; ubi remove recovery ; led $bootled_rec off -+boot_serial_write_bl2=loadx $loadaddr 115200 && run boot_write_bl2 -+boot_serial_write_fip=loadx $loadaddr 115200 && run boot_write_fip ++boot_serial_write_bl2=loadx $loadaddr 115200 && run snand_write_bl2 ++boot_serial_write_fip=loadx $loadaddr 115200 && run ubi_write_fip +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf +boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done +boot_tftp_production=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && ubi part ubi && run ubi_write_production ubi_prepare_rootfs ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp_recovery=tftpboot $loadaddr $bootfile && iminfo $loadaddr && ubi part ubi && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi -+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run boot_write_bl2 -+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run boot_write_fip ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip +boot_ubi=ubi part ubi && run boot_production ; run boot_recovery -+boot_write_bl2=mtd erase bl2 && mtd write spi-nand0 $loadaddr 0x0 0x20000 && mtd write spi-nand0 $loadaddr 0x20000 0x20000 && mtd write spi-nand0 $loadaddr 0x40000 0x20000 && mtd write spi-nand0 $loadaddr 0x60000 0x20000 -+boot_write_fip=mtd erase fip && mtd write fip $loadaddr -+check_ubi=ubi part ubi || run ubi_format -+reset_factory=mw $loadaddr 0x0 0x100000 ; ubi part ubi ; ubi write $loadaddr ubootenv 0x100000 ; ubi write $loadaddr ubootenv2 0x100000 ; ubi remove rootfs_data -+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset ++snand_write_bl2=mtd erase bl2 && mtd write spi-nand0 $loadaddr 0x0 0x20000 && mtd write spi-nand0 $loadaddr 0x20000 0x20000 && mtd write spi-nand0 $loadaddr 0x40000 0x20000 && mtd write spi-nand0 $loadaddr 0x60000 0x20000 ++reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi part ubi ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 +ubi_write_production=ubi check fit && env exists replacevol && ubi remove fit ; if ubi check fit ; then else run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ; fi +ubi_write_recovery=ubi check recovery && env exists replacevol && ubi remove recovery ; if ubi check recovery ; then else run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize ; fi -+_create_env=ubi create ubootenv 0x100000 dynamic ; ubi create ubootenv2 0x100000 dynamic ++_create_env=ubi create ubootenv 0x1f000 dynamic ; ubi create ubootenv2 0x1f000 dynamic +_init_env=setenv _init_env ; if ubi check ubootenv && ubi check ubootenv2 ; then else run _create_env ; fi ; setenv _create_env ; saveenv || run ubi_format ; saveenv || run ubi_format -+_firstboot=setenv _firstboot ; run _switch_to_menu ; run ethaddr_factory ; run check_ubi ; run _init_env ; run boot_first ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run ethaddr_factory ; run _init_env ; run boot_first +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch index aad6c53b9bb929..bbd05fe41f99e8 100644 --- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch +++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch @@ -841,7 +841,7 @@ +}; --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -1306,6 +1306,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ +@@ -1423,6 +1423,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7623a-unielec-u7623-02-emmc.dtb \ mt7622-bananapi-bpi-r64.dtb \ mt7622-linksys-e8450-ubi.dtb \ @@ -1019,7 +1019,7 @@ DECLARE_GLOBAL_DATA_PTR; -@@ -412,6 +413,20 @@ static int initr_onenand(void) +@@ -397,6 +398,20 @@ static int initr_onenand(void) } #endif @@ -1040,7 +1040,7 @@ #ifdef CONFIG_MMC static int initr_mmc(void) { -@@ -713,6 +728,9 @@ static init_fnc_t init_sequence_r[] = { +@@ -692,6 +707,9 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_NMBM_MTD initr_nmbm, #endif diff --git a/package/boot/uboot-mediatek/patches/420-add-support-for-RAVPower-RP-WD009.patch b/package/boot/uboot-mediatek/patches/420-add-support-for-RAVPower-RP-WD009.patch index 3cd4d1b2df3253..4ee87ce3d2252c 100644 --- a/package/boot/uboot-mediatek/patches/420-add-support-for-RAVPower-RP-WD009.patch +++ b/package/boot/uboot-mediatek/patches/420-add-support-for-RAVPower-RP-WD009.patch @@ -22,7 +22,7 @@ Subject: [PATCH] add support for RAVPower RP-WD009 --- a/arch/mips/dts/Makefile +++ b/arch/mips/dts/Makefile -@@ -25,6 +25,7 @@ dtb-$(CONFIG_TARGET_OCTEON_EBB7304) += m +@@ -26,6 +26,7 @@ dtb-$(CONFIG_TARGET_OCTEON_EBB7304) += m dtb-$(CONFIG_TARGET_OCTEON_NIC23) += mrvl,octeon-nic23.dtb dtb-$(CONFIG_BOARD_NETGEAR_CG3100D) += netgear,cg3100d.dtb dtb-$(CONFIG_BOARD_NETGEAR_DGND3700V2) += netgear,dgnd3700v2.dtb diff --git a/package/boot/uboot-mediatek/patches/421-zbtlink_zbt-wg3526-16m.patch b/package/boot/uboot-mediatek/patches/421-zbtlink_zbt-wg3526-16m.patch new file mode 100644 index 00000000000000..b9b241a51d494f --- /dev/null +++ b/package/boot/uboot-mediatek/patches/421-zbtlink_zbt-wg3526-16m.patch @@ -0,0 +1,314 @@ +--- /dev/null ++++ b/configs/mt7621_zbtlink_zbt-wg3526-16m_defconfig +@@ -0,0 +1,138 @@ ++CONFIG_MIPS=y ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_SYS_MALLOC_LEN=0x100000 ++CONFIG_SPL_LIBCOMMON_SUPPORT=y ++CONFIG_SPL_LIBGENERIC_SUPPORT=y ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_ENV_SIZE=0x1000 ++CONFIG_ENV_IS_IN_MTD=y ++CONFIG_ENV_MTD_NAME="nor0" ++CONFIG_ENV_SIZE_REDUND=0x10000 ++CONFIG_ENV_SIZE=0x10000 ++CONFIG_ENV_OFFSET=0x30000 ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_RESET_BUTTON_SETTLE_DELAY=400 ++CONFIG_BOOTP_SEND_HOSTNAME=y ++# CONFIG_BOOTSTD is not set ++CONFIG_DEFAULT_ENV_FILE="zbtlink_zbt-wg3526-16m_env" ++CONFIG_DEFAULT_DEVICE_TREE="zbtlink,zbt-wg3526" ++CONFIG_SPL_BSS_MAX_SIZE=0x80000 ++CONFIG_SPL_BSS_START_ADDR=0x80140000 ++CONFIG_SPL_SERIAL=y ++CONFIG_SPL_SYS_MALLOC_F_LEN=0x40000 ++CONFIG_SPL=y ++CONFIG_DEBUG_UART_BASE=0xbe000c00 ++CONFIG_DEBUG_UART_CLOCK=50000000 ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_SYS_LOAD_ADDR=0x83000000 ++CONFIG_SYS_MIPS_TIMER_FREQ=440000000 ++CONFIG_ARCH_MTMIPS=y ++CONFIG_SOC_MT7621=y ++# CONFIG_MIPS_CACHE_SETUP is not set ++# CONFIG_MIPS_CACHE_DISABLE is not set ++CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y ++CONFIG_MIPS_BOOT_FDT=y ++CONFIG_DEBUG_UART=y ++CONFIG_TPL_SYS_MALLOC_F_LEN=0x1000 ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++# CONFIG_FIT_ENABLE_SHA256_SUPPORT is not set ++CONFIG_HUSH_PARSER=y ++CONFIG_LOGLEVEL=6 ++# CONFIG_LOG is not set ++# CONFIG_SYS_LONGHELP is not set ++# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set ++CONFIG_SYS_CONSOLE_INFO_QUIET=y ++CONFIG_SPL_SYS_MALLOC_SIMPLE=y ++CONFIG_SPL_NOR_SUPPORT=y ++CONFIG_TPL=y ++# CONFIG_TPL_FRAMEWORK is not set ++CONFIG_LEGACY_IMAGE_FORMAT=y ++# CONFIG_BOOTM_NETBSD is not set ++# CONFIG_BOOTM_PLAN9 is not set ++# CONFIG_BOOTM_RTEMS is not set ++# CONFIG_BOOTM_VXWORKS is not set ++# CONFIG_EFI is not set ++# CONFIG_EFI_LOADER is not set ++CONFIG_CMD_BOOTMENU=y ++# CONFIG_CMD_BOOTEFI is not set ++# CONFIG_CMD_BOOTD is not set ++# CONFIG_CMD_BOOTP is not set ++CONFIG_CMD_BOOTM=y ++# CONFIG_CMD_BOOTDEV is not set ++# CONFIG_CMD_BOOTFLOW is not set ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_ECHO=y ++# CONFIG_CMD_ELF is not set ++# CONFIG_CMD_BOOTEFI_BOOTMGR is not set ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_MTDPART=y ++# CONFIG_CMD_PCI is not set ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_TFTPBOOT=y ++# CONFIG_CMD_UNLZ4 is not set ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_DOS_PARTITION=y ++# CONFIG_SPL_DOS_PARTITION is not set ++# CONFIG_ISO_PARTITION is not set ++# CONFIG_EFI_PARTITION is not set ++# CONFIG_SPL_EFI_PARTITION is not set ++CONFIG_PARTITION_TYPE_GUID=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++# CONFIG_NET_RANDOM_ETHADDR is not set ++# CONFIG_I2C is not set ++# CONFIG_INPUT is not set ++CONFIG_MMC=y ++# CONFIG_MMC_QUIRKS is not set ++# CONFIG_MMC_HW_PARTITIONING is not set ++CONFIG_MMC_MTK=y ++CONFIG_MTD=y ++CONFIG_DM_MTD=y ++CONFIG_SF_DEFAULT_SPEED=20000000 ++# CONFIG_SPI_FLASH_BAR is not set ++# CONFIG_SPI_FLASH_EON is not set ++# CONFIG_SPI_FLASH_GIGADEVICE is not set ++# CONFIG_SPI_FLASH_ISSI is not set ++# CONFIG_SPI_FLASH_MACRONIX is not set ++# CONFIG_SPI_FLASH_SPANSION is not set ++# CONFIG_SPI_FLASH_STMICRO is not set ++CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_XMC is not set ++# CONFIG_SPI_FLASH_XTX is not set ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_DEBUG_UART_SHIFT=2 ++CONFIG_SPI=y ++CONFIG_MT7621_SPI=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_RESETCTL=y ++# CONFIG_SYS_XTRACE is not set ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_WDT=y ++CONFIG_WDT_MT7621=y ++# CONFIG_BINMAN_FDT is not set ++CONFIG_LZMA=y ++CONFIG_SPL_LZMA=y ++# CONFIG_GZIP is not set +--- /dev/null ++++ b/zbtlink_zbt-wg3526-16m_env +@@ -0,0 +1,36 @@ ++ethaddr_factory=mtd read factory $loadaddr 0x0 0x10000 ; setexpr macoffs $loadaddr + 0xe000 ; env readmem -b ethaddr $macoffs 0x6 ; setenv ethaddr_factory ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x83000000 ++bootcmd=run boot_nor ++bootdelay=0 ++bootfile=openwrt-ramips-mt7621-zbtlink_zbt-wg3526-16m-initramfs-kernel.bin ++bootfile_uboot=u-boot-mt7621.bin ++bootfile_upg=openwrt-ramips-mt7621-zbtlink_zbt-wg3526-16m-squashfs-sysupgrade.bin ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot system from flash.=run boot_nor ; run bootmenu_confirm_return ++bootmenu_3=Load system via TFTP then write to flash.=run boot_tftp_sysupgrade ; run bootmenu_confirm_return ++bootmenu_4=Load U-Boot via TFTP then write to flash.=run boot_tftp_write_uboot ; run bootmenu_confirm_return ++bootmenu_5=Reset all settings to factory defaults.=run reset_factory ; reset ++bootmenu_6=Reboot.=reset ++boot_first=if button reset ; then run boot_tftp ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_tftp_forever ++boot_nor=bootm 0x1fc50000 ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr ++boot_tftp_forever=while true ; do run boot_tftp ; sleep 1 ; done ++boot_tftp_sysupgrade=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && run nor_write_production ++boot_tftp_write_uboot=tftpboot $loadaddr $bootfile_uboot && run nor_write_uboot ++reset_factory=mtd erase u-boot-env 0x0 0x10000 && reset ++nor_pad_size=setexpr image_eb $filesize / 0x1000 ; setexpr tmp1 image_size % 0x1000 ; test 0x$tmp1 -gt 0 && setexpr image_eb $image_eb + 1 ; setexpr image_eb $image_eb * 0x1000 ++nor_write_production=run nor_pad_size ; test 0x$image_eb -le 0xfb0000 && mtd erase firmware 0x0 0x$image_eb && mtd write firmware $loadaddr 0x0 $filesize ++nor_write_uboot=mtd erase u-boot 0x0 0x30000 && mtd write u-boot $loadaddr 0x0 0x30000 ++_init_env=setenv _init_env ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run ethaddr_factory ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/arch/mips/dts/zbtlink,zbt-wg3526.dts +@@ -0,0 +1,131 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2022 MediaTek Inc. All rights reserved. ++ * ++ * Author: Weijie Gao ++ */ ++ ++/dts-v1/; ++ ++#include "mt7621.dtsi" ++#include ++ ++/ { ++ compatible = "zbtlink,zbt-wg3526", "mediatek,mt7621-rfb", "mediatek,mt7621-soc"; ++ model = "Zbtlink WG3526"; ++ ++ aliases { ++ ethernet0 = ð ++ serial0 = &uart0; ++ spi0 = &spi; ++ }; ++ ++ chosen { ++ stdout-path = &uart0; ++ }; ++ ++ keys { ++ compatible = "gpio-keys"; ++ ++ reset { ++ label = "reset"; ++ gpios = <&gpio 18 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led_status: status { ++ label = "green:status"; ++ gpios = <&gpio 24 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++}; ++ ++&pinctrl { ++ state_default: pin_state { ++ gpios { ++ groups = "i2c", "uart3", "pcie reset"; ++ function = "gpio"; ++ }; ++ ++ wdt { ++ groups = "wdt"; ++ function = "wdt rst"; ++ }; ++ ++ jtag { ++ groups = "jtag"; ++ function = "jtag"; ++ }; ++ }; ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&gpio { ++ status = "okay"; ++}; ++ ++&spi { ++ status = "okay"; ++ num-cs = <2>; ++ ++ spi-flash@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "jedec,spi-nor"; ++ spi-max-frequency = <25000000>; ++ reg = <0>; ++ ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "u-boot"; ++ reg = <0x0 0x30000>; ++ }; ++ ++ partition@30000 { ++ label = "u-boot-env"; ++ reg = <0x30000 0x10000>; ++ }; ++ ++ factory: partition@40000 { ++ label = "factory"; ++ reg = <0x40000 0x10000>; ++ read-only; ++ }; ++ ++ firmware: partition@50000 { ++ compatible = "denx,uimage"; ++ label = "firmware"; ++ reg = <0x50000 0xfb0000>; ++ }; ++ }; ++ }; ++}; ++ ++ð { ++ status = "okay"; ++}; ++ ++&mmc { ++ cap-sd-highspeed; ++ ++ status = "okay"; ++}; ++ ++&ssusb { ++ status = "okay"; ++}; ++ ++&u3phy { ++ status = "okay"; ++}; diff --git a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch index 1567ba537c052a..c48a934b7440c3 100644 --- a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch +++ b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/configs/mt7986a_bpi-r3-emmc_defconfig -@@ -0,0 +1,196 @@ +@@ -0,0 +1,197 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -13,6 +13,7 @@ +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3_emmc_env" +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-emmc.dtb" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART_BASE=0x11002000 +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y @@ -199,7 +200,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-nor_defconfig -@@ -0,0 +1,195 @@ +@@ -0,0 +1,193 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -212,6 +213,7 @@ +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3_nor_env" +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-emmc.dtb" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART_BASE=0x11002000 +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y @@ -271,9 +273,6 @@ +CONFIG_CMD_SMC=y +CONFIG_CMD_TFTPBOOT=y +CONFIG_CMD_TFTPSRV=y -+CONFIG_CMD_UBI=y -+CONFIG_CMD_UBI_RENAME=y -+CONFIG_CMD_UBIFS=y +CONFIG_CMD_ASKENV=y +CONFIG_CMD_PART=y +CONFIG_CMD_RARP=y @@ -397,7 +396,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-sd_defconfig -@@ -0,0 +1,196 @@ +@@ -0,0 +1,197 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -410,6 +409,7 @@ +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3_sdmmc_env" +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-sd.dtb" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART_BASE=0x11002000 +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y @@ -596,7 +596,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-snand_defconfig -@@ -0,0 +1,197 @@ +@@ -0,0 +1,198 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -609,6 +609,7 @@ +CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3_snand_env" +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-emmc.dtb" +CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_DEBUG_UART_BASE=0x11002000 +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y @@ -796,12 +797,12 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/bananapi_bpi-r3_sdmmc_env -@@ -0,0 +1,80 @@ +@@ -0,0 +1,81 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x46000000 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 -+bootargs=root=/dev/mmcblk0p65 ++bootargs=root=/dev/fit0 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_sdmmc ; fi +bootconf=config-mt7986a-bananapi-bpi-r3 +bootconf_base=config-mt7986a-bananapi-bpi-r3 @@ -853,26 +854,27 @@ +sdmmc_read_emmc_install=part start mmc 0 install part_addr && setexpr offset $part_addr + 0x3800 && mmc read $loadaddr $offset 0x4000 +sdmmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol +sdmmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol -+mtd_write_fip=mtd erase fip && mtd write fip $loadaddr -+mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr ++snand_write_bl2=mtd erase bl2 0x0 0x100000 && mtd write bl2 $loadaddr 0x0 0x40000 && mtd write bl2 $loadaddr 0x40000 0x40000 && mtd write bl2 $loadaddr 0x80000 0x40000 && mtd write bl2 $loadaddr 0xc0000 0x40000 ++nor_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr ++nor_write_fip=mtd erase fip && mtd write fip $loadaddr +nor_pad_size=imsz $loadaddr image_size ; setexpr image_eb 0x$image_size / 0x10000 ; setexpr tmp1 0x$image_size % 0x10000 ; test 0x$tmp1 -gt 0 && setexpr image_eb 0x$image_eb + 1 ; setexpr image_eb $image_eb * 0x10000 +nor_erase_env=mtd erase u-boot-env +nor_write_production=run nor_pad_size ; test 0x$image_eb -le 0x3000000 && mtd erase fit && mtd write fit $loadaddr 0x0 $image_eb +nor_write_recovery=run nor_pad_size ; test 0x$image_eb -le 0x900000 && mtd erase recovery 0x0 0x$image_eb && mtd write recovery $loadaddr 0x0 $image_eb +nor_init=run nor_init_bl && run nor_init_openwrt -+nor_init_bl=run sdmmc_read_nor_bl2 && run mtd_write_bl2 && run sdmmc_read_nor_fip && run mtd_write_fip && run nor_erase_env ++nor_init_bl=run sdmmc_read_nor_bl2 && run nor_write_bl2 && run sdmmc_read_nor_fip && run nor_write_fip && run nor_erase_env +nor_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run nor_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run nor_write_production -+ubi_create_env=ubi create ubootenv 0x100000 dynamic 0 ; ubi create ubootenv2 0x100000 dynamic 1 +ubi_format=ubi detach ; mtd erase ubi && ubi part ubi -+ubi_init=run ubi_init_bl && run ubi_format && run ubi_create_env && run ubi_init_openwrt && run ubi_init_emmc_install ++ubi_init=run ubi_format && run ubi_init_bl && run ubi_init_openwrt && run ubi_init_emmc_install +ubi_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run ubi_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run ubi_write_production -+ubi_init_bl=run sdmmc_read_snand_bl2 && run mtd_write_bl2 && run sdmmc_read_snand_fip && run mtd_write_fip ++ubi_init_bl=run sdmmc_read_snand_bl2 && run snand_write_bl2 && run sdmmc_read_snand_fip && run ubi_write_fip +ubi_init_emmc_install=run sdmmc_read_emmc_install && run ubi_write_emmc_install +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 +ubi_write_emmc_install=ubi check emmc_install && ubi remove emmc_install ; ubi create emmc_install 0x800000 dynamic ; ubi write $loadaddr emmc_install 0x800000 -+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize -+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic 3 && ubi write $loadaddr recovery $filesize ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize +_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title @@ -884,7 +886,7 @@ +serverip=192.168.1.254 +loadaddr=0x46000000 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 -+bootargs=root=/dev/mtdblock0p1 ++bootargs=root=/dev/fit0 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_nor ; fi +bootconf=config-mt7986a-bananapi-bpi-r3 +bootconf_base=config-mt7986a-bananapi-bpi-r3 @@ -911,7 +913,7 @@ +bootmenu_4=Load production system via TFTP then write to flash.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return +bootmenu_5=Load recovery system via TFTP then write to flash.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return +bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to flash.=run boot_tftp_write_fip ; run bootmenu_confirm_return -+bootmenu_7=Load BL2 preloader via TFTP then write to flash.=run boot_tftp_write_preloader ; run bootmenu_confirm_return ++bootmenu_7=Load BL2 preloader via TFTP then write to flash.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return +bootmenu_8=Reboot.=reset +bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset +boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu @@ -924,13 +926,13 @@ +boot_tftp_production=run boot_update_conf ; tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run nor_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp_recovery=run boot_update_conf ; tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run nor_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp=run boot_update_conf ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf -+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run boot_write_fip -+boot_tftp_write_preloader=tftpboot $loadaddr $bootfile_bl2 && run boot_write_preloader ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run nor_write_fip ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run nor_write_bl2 +boot_update_conf=if mmc partconf 0 ; then setenv bootconf $bootconf_base#$bootconf_nor#$bootconf_emmc ; else setenv bootconf $bootconf_base#$bootconf_nor#$bootconf_sd ; fi +boot_nor=run boot_production ; run boot_recovery -+boot_write_fip=mtd erase fip && mtd write fip $loadaddr -+boot_write_preloader=mtd erase bl2 && mtd write bl2 $loadaddr +reset_factory=mtd erase u-boot-env ++nor_write_fip=mtd erase fip && mtd write fip $loadaddr ++nor_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr +nor_read_production=mtd read fit $loadaddr 0x0 0x20000 && imsz $loadaddr image_size && mtd read fit $loadaddr 0x0 $image_size +nor_read_recovery=mtd read recovery $loadaddr 0x0 0x20000 && imsz $loadaddr image_size && mtd read recovery $loadaddr 0x0 $image_size +nor_pad_size=imsz $loadaddr image_size ; setexpr image_eb 0x$image_size / 0x10000 ; setexpr tmp1 0x$image_size % 0x10000 ; test 0x$tmp1 -gt 0 && setexpr image_eb 0x$image_eb + 1 ; setexpr image_eb $image_eb * 0x10000 @@ -942,12 +944,12 @@ +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" --- /dev/null +++ b/bananapi_bpi-r3_snand_env -@@ -0,0 +1,74 @@ +@@ -0,0 +1,73 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x46000000 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 -+bootargs=root=/dev/ubiblock0_2p1 ++bootargs=root=/dev/fit0 +bootconf=config-mt7986a-bananapi-bpi-r3 +bootconf_base=config-mt7986a-bananapi-bpi-r3 +bootconf_nor=mt7986a-bananapi-bpi-r3-nor @@ -982,28 +984,27 @@ +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever +boot_production=run boot_update_conf ; led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off +boot_recovery=run boot_update_conf ; led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off -+boot_ubi=run boot_update_conf ; run boot_production ; run boot_recovery ++boot_ubi=run boot_production ; run boot_recovery +boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done +boot_tftp_production=run boot_update_conf ; tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp_recovery=run boot_update_conf ; tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp=run boot_update_conf ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf -+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory -+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2 -+boot_update_conf=if mmc partconf 0 ; then setenv bootconf $bootconf_base#$bootconf_nand#$bootconf_emmc ; else setenv bootconf $bootconf_base#$bootconf_nand#$bootconf_sd ; fi ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++boot_update_conf=if mmc partconf 0 ; then setenv bootconf $bootconf_base#$bootconf_nand#$bootconf_emmc ; else setenv bootconf $bootconf_base#$bootconf_nand#$bootconf_sd ; fi +part_default=production +part_recovery=recovery -+reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800 -+mtd_write_fip=mtd erase fip && mtd write fip $loadaddr -+mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr -+ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic 0 ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic 1 -+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset ++reset_factory=ubi part ubi ; mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ++snand_write_bl2=mtd erase bl2 0x0 0x100000 && mtd write bl2 $loadaddr 0x0 0x40000 && mtd write bl2 $loadaddr 0x40000 0x40000 && mtd write bl2 $loadaddr 0x80000 0x40000 && mtd write bl2 $loadaddr 0xc0000 0x40000 ++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi +ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery +ubi_read_emmc_install=ubi check emmc_install && ubi read $loadaddr emmc_install +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data -+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize -+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic 3 && ubi write $loadaddr recovery $filesize ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize +mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size +emmc_init=mmc dev 0 && mmc bootbus 0 0 0 0 && run emmc_init_bl && run emmc_init_openwrt ; env default bootcmd ; saveenv ; saveenv +emmc_init_bl=run ubi_read_emmc_install && setenv fileaddr $loadaddr && run emmc_write_bl2 && setexpr fileaddr $loadaddr + 0x100000 && run emmc_write_fip && setexpr fileaddr $loadaddr + 0x500000 && run emmc_write_hdr @@ -1024,7 +1025,7 @@ +serverip=192.168.1.254 +loadaddr=0x46000000 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 -+bootargs=root=/dev/mmcblk0p65 ++bootargs=root=/dev/fit0 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi +bootconf=config-mt7986a-bananapi-bpi-r3 +bootconf_base=config-mt7986a-bananapi-bpi-r3 @@ -1058,7 +1059,7 @@ +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever +boot_production=run boot_update_conf ; led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off +boot_recovery=run boot_update_conf ; led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off -+boot_emmc=run boot_update_conf ; run boot_production ; run boot_recovery ++boot_emmc=run boot_production ; run boot_recovery +boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done +boot_tftp_production=run boot_update_conf ; tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run emmc_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi +boot_tftp_recovery=run boot_update_conf ; tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run emmc_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi @@ -1081,3 +1082,32 @@ +_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- a/arch/arm/dts/mt7986a-bpi-r3-sd.dts ++++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts +@@ -235,22 +235,13 @@ + + partition@0 { + label = "bl2"; +- reg = <0x0 0x80000>; ++ reg = <0x0 0x200000>; + }; + +- partition@80000 { +- label = "factory"; +- reg = <0x80000 0x300000>; +- }; +- +- partition@380000 { +- label = "fip"; +- reg = <0x380000 0x200000>; +- }; +- +- partition@580000 { ++ partition@200000 { + label = "ubi"; +- reg = <0x580000 0x7a80000>; ++ reg = <0x200000 0x7e00000>; ++ compatible = "linux,ubi"; + }; + }; + }; diff --git a/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch b/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch new file mode 100644 index 00000000000000..667b7570ac2e82 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch @@ -0,0 +1,779 @@ +--- /dev/null ++++ b/configs/mt7986a_bpi-r3-mini-emmc_defconfig +@@ -0,0 +1,203 @@ ++CONFIG_ARM=y ++CONFIG_POSITION_INDEPENDENT=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_TARGET_MT7986=y ++CONFIG_TEXT_BASE=0x41e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-mini" ++CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3-mini_emmc_env" ++CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-mini.dtb" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y ++CONFIG_DEBUG_UART_BASE=0x11002000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_DEBUG_UART=y ++CONFIG_SYS_LOAD_ADDR=0x46000000 ++CONFIG_SMBIOS_PRODUCT_NAME="" ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++CONFIG_FIT_ENABLE_SHA256_SUPPORT=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_LOGLEVEL=7 ++CONFIG_LOG=y ++CONFIG_SYS_PROMPT="MT7986> " ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_BOOTP=y ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_ECHO=y ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FDT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++CONFIG_CMD_LICENSE=y ++CONFIG_CMD_LINK_LOCAL=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MDIO=y ++CONFIG_CMD_MII=y ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_TFTPBOOT=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++CONFIG_CMD_UBIFS=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_UUID=y ++CONFIG_DISPLAY_CPUINFO=y ++CONFIG_DM_MDIO=y ++CONFIG_DM_MMC=y ++CONFIG_DM_MTD=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_USB=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_REDUNDAND_ENVIRONMENT=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_PARTITION_UUIDS=y ++CONFIG_NETCONSOLE=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_DM_GPIO=y ++CONFIG_DM_SCSI=y ++CONFIG_AHCI=y ++CONFIG_AHCI_PCI=y ++CONFIG_SCSI_AHCI=y ++CONFIG_SCSI=y ++CONFIG_CMD_SCSI=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_PHY_ETHERNET_ID=y ++CONFIG_PHY_FIXED=y ++CONFIG_MTK_AHCI=y ++CONFIG_DM_ETH=y ++CONFIG_DM_ETH_PHY=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PHY_AIROHA=y ++CONFIG_PHY_AIROHA_EN8811H=y ++CONFIG_PHY_AIROHA_FW_IN_MMC=y ++CONFIG_PCI=y ++CONFIG_MTD=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_DM_PCI=y ++CONFIG_PCIE_MEDIATEK=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7622=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00 ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_RAM=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_MMC=y ++CONFIG_MMC_DEFAULT_DEV=1 ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_MMC_SUPPORTS_TUNING=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_SPI=y ++CONFIG_DM_SPI=y ++CONFIG_MTK_SPI_NAND=y ++CONFIG_MTK_SPI_NAND_MTD=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_WDT_MTK=y ++CONFIG_LZO=y ++CONFIG_ZSTD=y ++CONFIG_HEXDUMP=y ++CONFIG_RANDOM_UUID=y ++CONFIG_REGEX=y ++CONFIG_USB=y ++CONFIG_USB_HOST=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_XHCI_MTK=y ++CONFIG_USB_STORAGE=y ++CONFIG_OF_EMBED=y ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_ENV_OFFSET=0x400000 ++CONFIG_ENV_OFFSET_REDUND=0x440000 ++CONFIG_ENV_SIZE=0x40000 ++CONFIG_ENV_SIZE_REDUND=0x40000 ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7986=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_HEXDUMP=y ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTK_SPIM=y ++#CONFIG_MTK_SNOR=y ++CONFIG_DM_SPI_FLASH=y ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set ++CONFIG_CMD_SF=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_NAND_TRIMFFS=y ++CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_SERVERIP=y ++CONFIG_SERVERIP="192.168.1.254" +--- /dev/null ++++ b/configs/mt7986a_bpi-r3-mini-snand_defconfig +@@ -0,0 +1,203 @@ ++CONFIG_ARM=y ++CONFIG_POSITION_INDEPENDENT=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_TARGET_MT7986=y ++CONFIG_TEXT_BASE=0x41e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-mini" ++CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r3-mini_snand_env" ++CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-bpi-r3-mini.dtb" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y ++CONFIG_DEBUG_UART_BASE=0x11002000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_DEBUG_UART=y ++CONFIG_SYS_LOAD_ADDR=0x46000000 ++CONFIG_SMBIOS_PRODUCT_NAME="" ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++CONFIG_FIT_ENABLE_SHA256_SUPPORT=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_LOGLEVEL=7 ++CONFIG_LOG=y ++CONFIG_SYS_PROMPT="MT7986> " ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_BOOTP=y ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_ECHO=y ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FDT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++CONFIG_CMD_LICENSE=y ++CONFIG_CMD_LINK_LOCAL=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MDIO=y ++CONFIG_CMD_MII=y ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_TFTPBOOT=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++CONFIG_CMD_UBIFS=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_UUID=y ++CONFIG_DISPLAY_CPUINFO=y ++CONFIG_DM_MMC=y ++CONFIG_DM_MTD=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_USB=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_REDUNDAND_ENVIRONMENT=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_PARTITION_UUIDS=y ++CONFIG_NETCONSOLE=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_DM_GPIO=y ++CONFIG_DM_SCSI=y ++CONFIG_AHCI=y ++CONFIG_AHCI_PCI=y ++CONFIG_SCSI_AHCI=y ++CONFIG_SCSI=y ++CONFIG_CMD_SCSI=y ++CONFIG_DM_MDIO=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_PHY_ETHERNET_ID=y ++CONFIG_PHY_FIXED=y ++CONFIG_MTK_AHCI=y ++CONFIG_DM_ETH=y ++CONFIG_DM_ETH_PHY=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PCI=y ++CONFIG_MTD=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_DM_PCI=y ++CONFIG_PCIE_MEDIATEK=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7622=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00 ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_RAM=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_MMC=y ++CONFIG_MMC_DEFAULT_DEV=1 ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_MMC_SUPPORTS_TUNING=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_SPI=y ++CONFIG_DM_SPI=y ++CONFIG_MTK_SPI_NAND=y ++CONFIG_MTK_SPI_NAND_MTD=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_WDT_MTK=y ++CONFIG_LZO=y ++CONFIG_ZSTD=y ++CONFIG_HEXDUMP=y ++CONFIG_RANDOM_UUID=y ++CONFIG_REGEX=y ++CONFIG_USB=y ++CONFIG_USB_HOST=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_XHCI_MTK=y ++CONFIG_USB_STORAGE=y ++CONFIG_OF_EMBED=y ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_UBI=y ++CONFIG_ENV_UBI_PART="ubi" ++CONFIG_ENV_SIZE=0x1f000 ++CONFIG_ENV_SIZE_REDUND=0x1f000 ++CONFIG_ENV_UBI_VOLUME="ubootenv" ++CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2" ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PHY_AIROHA=y ++CONFIG_PHY_AIROHA_EN8811H=y ++CONFIG_PHY_AIROHA_FW_IN_UBI=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7986=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_HEXDUMP=y ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTK_SPIM=y ++#CONFIG_MTK_SNOR=y ++#CONFIG_DM_SPI_FLASH=y ++#CONFIG_SPI_FLASH_MTD=y ++#CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set ++#CONFIG_CMD_SF=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_NAND_TRIMFFS=y ++CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_SERVERIP=y +--- /dev/null ++++ b/bananapi_bpi-r3-mini_snand_env +@@ -0,0 +1,61 @@ ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x46000000 ++console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 ++bootargs=root=ubi.block=0,fit root=/dev/fit0 ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi ++bootconf=config-mt7986a-bananapi-bpi-r3-mini ++bootdelay=0 ++bootfile=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-initramfs-recovery.itb ++bootfile_bl2=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-preloader.bin ++bootfile_fip=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-bl31-uboot.fip ++bootfile_upg=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb ++bootfile_en8811h_fw=EthMD32.bin ++bootled_pwr=green:status ++bootled_rec=blue:status ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) [SPI-NAND] ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Load Airoha EN8811H firmware via TFTP then write to NAND.=run boot_tftp_write_en8811h_fw ; run bootmenu_confirm_return ++bootmenu_7=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return ++bootmenu_8=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return ++bootmenu_9=Reboot.=reset ++bootmenu_10=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off ++boot_recovery=led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off ++boot_ubi=run boot_production ; run boot_recovery ++boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++boot_tftp_write_en8811h_fw=tftpboot $loadaddr $bootfile_en8811h_fw && run ubi_write_en8811h_fw ++part_default=production ++part_recovery=recovery ++reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x40000 && mtd write bl2 $loadaddr 0x40000 0x40000 && mtd write bl2 $loadaddr 0x80000 0x40000 && mtd write bl2 $loadaddr 0xc0000 0x40000 ++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic ++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi ++ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs ++ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery ++ubi_read_emmc_install=ubi check emmc_install && ubi read $loadaddr emmc_install ++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_en8811h_fw=ubi check en8811h-fw && ubi remove en8811h-fw ; ubi create en8811h-fw 0x24000 static ; ubi write $loadaddr en8811h-fw 0x24000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize ++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/bananapi_bpi-r3-mini_emmc_env +@@ -0,0 +1,59 @@ ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x46000000 ++console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 ++bootargs=root=/dev/fit0 ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi ++bootconf=config-mt7986a-bananapi-bpi-r3-mini ++bootdelay=0 ++bootfile=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-initramfs-recovery.itb ++bootfile_bl2=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-emmc-preloader.bin ++bootfile_fip=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-emmc-bl31-uboot.fip ++bootfile_upg=openwrt-mediatek-filogic-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb ++bootfile_en8811h_fw=EthMD32.bin ++bootled_pwr=green:status ++bootled_rec=blue:status ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) [eMMC] ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot production system from eMMC.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from eMMC.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Load Airoha EN8811H firmware via TFTP then write to eMMC.=run boot_tftp_write_en8811h_fw ; run bootmenu_confirm_return ++bootmenu_7=Load BL31+U-Boot FIP via TFTP then write to eMMC.=run boot_tftp_write_fip ; run bootmenu_confirm_return ++bootmenu_8=Load BL2 preloader via TFTP then write to eMMC.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return ++bootmenu_9=Reboot.=reset ++bootmenu_10=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off ++boot_recovery=led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off ++boot_emmc=run boot_production ; run boot_recovery ++boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run emmc_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run emmc_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run emmc_write_fip ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run emmc_write_bl2 ++boot_tftp_write_en8811h_fw=tftpboot $loadaddr $bootfile_en8811h_fw && run emmc_write_en8811h_fw ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf ++mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size ++mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200 ++part_default=production ++part_recovery=recovery ++reset_factory=eraseenv && reset ++emmc_read_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_read_vol ++emmc_read_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_read_vol ++emmc_write_en8811h_fw=mmc partconf 0 1 2 2 && mmc erase 0x0 0x120 && mmc write $fileaddr 0x0 0x120 ; mmc partconf 0 1 1 0 ++emmc_write_bl2=mmc partconf 0 1 1 1 && mmc erase 0x0 0x400 && mmc write $fileaddr 0x0 0x400 ; mmc partconf 0 1 1 0 ++emmc_write_fip=mmc erase 0x3400 0x2000 && mmc write $fileaddr 0x3400 0x2000 && mmc erase 0x2000 0x800 ++emmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol ++emmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol ++_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/arch/arm/dts/mt7986a-bpi-r3-mini.dts +@@ -0,0 +1,238 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++/dts-v1/; ++#include "mt7986.dtsi" ++#include ++#include ++ ++/ { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ model = "Bananapi BPi-R3 Mini"; ++ compatible = "mediatek,mt7986", "mediatek,mt7986-rfb"; ++ ++ chosen { ++ stdout-path = &uart0; ++ tick-timer = &timer0; ++ }; ++ ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x80000000>; ++ }; ++ ++ gpio-keys { ++ compatible = "gpio-keys"; ++ ++ button-reset { ++ label = "reset"; ++ linux,code = ; ++ gpios = <&gpio 7 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ status_led: led-0 { ++ label = "green:status"; ++ gpios = <&gpio 19 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ led-1 { ++ label = "blue:wlan2g"; ++ gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ led-2 { ++ label = "blue:wlan5g"; ++ gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; ++ }; ++ }; ++ ++ reg_1p8v: regulator-1p8v { ++ compatible = "regulator-fixed"; ++ regulator-name = "fixed-1.8V"; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ regulator-boot-on; ++ regulator-always-on; ++ }; ++ ++ reg_3p3v: regulator-3p3v { ++ compatible = "regulator-fixed"; ++ regulator-name = "fixed-3.3V"; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-boot-on; ++ regulator-always-on; ++ }; ++}; ++ ++ð { ++ status = "okay"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mdio_pins>; ++ ++ mediatek,gmac-id = <0>; ++ phy-mode = "2500base-x"; ++ phy-handle = <&phy14>; ++ ++ phy14: eth-phy@e { ++ compatible = "ethernet-phy-id03a2.a411"; ++ reg = <14>; ++ ++ airoha,rx-pol-reverse; ++ ++ reset-gpios = <&gpio 49 GPIO_ACTIVE_LOW>; ++ reset-assert-us = <10000>; ++ reset-deassert-us = <20000>; ++ }; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_default>; ++ bus-width = <8>; ++ max-frequency = <200000000>; ++ cap-mmc-highspeed; ++ cap-mmc-hw-reset; ++ vmmc-supply = <®_3p3v>; ++ vqmmc-supply = <®_1p8v>; ++ non-removable; ++ status = "okay"; ++}; ++ ++&pinctrl { ++ mdio_pins: mdio-pins { ++ mux { ++ function = "eth"; ++ groups = "mdc_mdio"; ++ }; ++ ++ conf-en8811-pwr-a { ++ pins = "GPIO_11"; ++ drive-strength = ; ++ bias-pull-down = ; ++ output-low; ++ }; ++ ++ conf-en8811-pwr-b { ++ pins = "GPIO_12"; ++ drive-strength = ; ++ bias-pull-down = ; ++ output-low; ++ }; ++ }; ++ ++ mmc0_pins_default: mmc0default { ++ mux { ++ function = "flash"; ++ groups = "emmc_51"; ++ }; ++ ++ conf-cmd-dat { ++ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2", ++ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5", ++ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD"; ++ input-enable; ++ drive-strength = ; ++ bias-pull-up = ; ++ }; ++ ++ conf-clk { ++ pins = "EMMC_CK"; ++ drive-strength = ; ++ bias-pull-down = ; ++ }; ++ ++ conf-dsl { ++ pins = "EMMC_DSL"; ++ bias-pull-down = ; ++ }; ++ ++ conf-rst { ++ pins = "EMMC_RSTB"; ++ drive-strength = ; ++ bias-pull-up = ; ++ }; ++ }; ++ ++ spi_flash_pins: spi0-pins-func-1 { ++ mux { ++ function = "flash"; ++ groups = "spi0", "spi0_wp_hold"; ++ }; ++ ++ conf-pu { ++ pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP"; ++ drive-strength = ; ++ bias-pull-up = ; ++ }; ++ ++ conf-pd { ++ pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO"; ++ drive-strength = ; ++ bias-pull-down = ; ++ }; ++ }; ++ ++ pwm_pins: pwm0-pins-func-1 { ++ mux { ++ function = "pwm"; ++ groups = "pwm0"; ++ }; ++ }; ++}; ++ ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm_pins>; ++ status = "okay"; ++}; ++ ++&spi0 { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&spi_flash_pins>; ++ status = "okay"; ++ must_tx; ++ enhance_timing; ++ dma_ext; ++ ipm_design; ++ support_quad; ++ tick_dly = <1>; ++ sample_sel = <0>; ++ ++ spi_nand@0 { ++ compatible = "spi-nand"; ++ reg = <0>; ++ spi-max-frequency = <20000000>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "bl2"; ++ reg = <0x0 0x200000>; ++ }; ++ ++ partition@200000 { ++ label = "ubi"; ++ reg = <0x200000 0x7e00000>; ++ }; ++ }; ++ }; ++ ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&watchdog { ++ status = "disabled"; ++}; diff --git a/package/boot/uboot-mediatek/patches/450-add-bpi-r4.patch b/package/boot/uboot-mediatek/patches/450-add-bpi-r4.patch new file mode 100644 index 00000000000000..c3c21fe2f50dba --- /dev/null +++ b/package/boot/uboot-mediatek/patches/450-add-bpi-r4.patch @@ -0,0 +1,998 @@ +--- /dev/null ++++ b/configs/mt7988a_bananapi_bpi-r4-emmc_defconfig +@@ -0,0 +1,180 @@ ++CONFIG_ARM=y ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_POSITION_INDEPENDENT=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_TEXT_BASE=0x41e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_SYS_PROMPT="MT7988> " ++CONFIG_TARGET_MT7988=y ++CONFIG_DEBUG_UART_BASE=0x11000000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_SYS_LOAD_ADDR=0x50000000 ++CONFIG_DEBUG_UART=y ++CONFIG_SYS_CBSIZE=512 ++CONFIG_SYS_PBSIZE=1049 ++CONFIG_DEFAULT_DEVICE_TREE="mt7988a-bananapi-bpi-r4-emmc" ++CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r4_emmc_env" ++CONFIG_DEFAULT_FDT_FILE="mediatek/mt7988a-bpi-r4-emmc.dtb" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y ++CONFIG_SMBIOS_PRODUCT_NAME="" ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++CONFIG_FIT_ENABLE_SHA256_SUPPORT=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_LOGLEVEL=7 ++CONFIG_LOG=y ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_BOOTP=y ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_ECHO=y ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FDT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++CONFIG_CMD_LICENSE=y ++CONFIG_CMD_LINK_LOCAL=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_TFTPBOOT=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++CONFIG_CMD_UBIFS=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_UUID=y ++CONFIG_DISPLAY_CPUINFO=y ++CONFIG_DM_MMC=y ++CONFIG_DM_MTD=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_USB=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_REDUNDAND_ENVIRONMENT=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_PARTITION_UUIDS=y ++CONFIG_NETCONSOLE=y ++CONFIG_DM_GPIO=y ++CONFIG_DM_SCSI=y ++CONFIG_AHCI=y ++CONFIG_AHCI_PCI=y ++CONFIG_SCSI_AHCI=y ++CONFIG_SCSI=y ++CONFIG_CMD_SCSI=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_MTK_AHCI=y ++CONFIG_PCI=y ++CONFIG_MTD=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_DM_PCI=y ++CONFIG_PCIE_MEDIATEK=y ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00 ++CONFIG_RAM=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_MMC=y ++CONFIG_MMC_DEFAULT_DEV=1 ++CONFIG_MMC_SUPPORTS_TUNING=y ++CONFIG_SPI=y ++CONFIG_DM_SPI=y ++CONFIG_MTK_SPI_NAND=y ++CONFIG_MTK_SPI_NAND_MTD=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_WDT_MTK=y ++CONFIG_LZO=y ++CONFIG_ZSTD=y ++CONFIG_HEXDUMP=y ++CONFIG_RANDOM_UUID=y ++CONFIG_REGEX=y ++CONFIG_USB=y ++CONFIG_USB_HOST=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_XHCI_MTK=y ++CONFIG_USB_STORAGE=y ++CONFIG_OF_EMBED=y ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_ENV_OFFSET=0x400000 ++CONFIG_ENV_OFFSET_REDUND=0x440000 ++CONFIG_ENV_SIZE=0x40000 ++CONFIG_ENV_SIZE_REDUND=0x40000 ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_PHY_FIXED=y ++CONFIG_DM_ETH=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7988=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTK_SPIM=y ++#CONFIG_MTK_SNOR=y ++CONFIG_DM_SPI_FLASH=y ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set ++CONFIG_CMD_SF=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_NAND_TRIMFFS=y ++CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_SERVERIP=y ++CONFIG_SERVERIP="192.168.1.254" +--- /dev/null ++++ b/configs/mt7988a_bananapi_bpi-r4-sdmmc_defconfig +@@ -0,0 +1,180 @@ ++CONFIG_ARM=y ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_POSITION_INDEPENDENT=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_TEXT_BASE=0x41e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_SYS_PROMPT="MT7988> " ++CONFIG_TARGET_MT7988=y ++CONFIG_DEBUG_UART_BASE=0x11000000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_SYS_LOAD_ADDR=0x50000000 ++CONFIG_DEBUG_UART=y ++CONFIG_SYS_CBSIZE=512 ++CONFIG_SYS_PBSIZE=1049 ++CONFIG_DEFAULT_DEVICE_TREE="mt7988a-bananapi-bpi-r4-sd" ++CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r4_sdmmc_env" ++CONFIG_DEFAULT_FDT_FILE="mediatek/mt7988a-bpi-r4-sd.dtb" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y ++CONFIG_SMBIOS_PRODUCT_NAME="" ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++CONFIG_FIT_ENABLE_SHA256_SUPPORT=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_LOGLEVEL=7 ++CONFIG_LOG=y ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_BOOTP=y ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_ECHO=y ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FDT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++CONFIG_CMD_LICENSE=y ++CONFIG_CMD_LINK_LOCAL=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_TFTPBOOT=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++CONFIG_CMD_UBIFS=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_UUID=y ++CONFIG_DISPLAY_CPUINFO=y ++CONFIG_DM_MMC=y ++CONFIG_DM_MTD=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_USB=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_REDUNDAND_ENVIRONMENT=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_PARTITION_UUIDS=y ++CONFIG_NETCONSOLE=y ++CONFIG_DM_GPIO=y ++CONFIG_DM_SCSI=y ++CONFIG_AHCI=y ++CONFIG_AHCI_PCI=y ++CONFIG_SCSI_AHCI=y ++CONFIG_SCSI=y ++CONFIG_CMD_SCSI=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_MTK_AHCI=y ++CONFIG_PCI=y ++CONFIG_MTD=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_DM_PCI=y ++CONFIG_PCIE_MEDIATEK=y ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00 ++CONFIG_RAM=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_MMC=y ++CONFIG_MMC_DEFAULT_DEV=1 ++CONFIG_MMC_SUPPORTS_TUNING=y ++CONFIG_SPI=y ++CONFIG_DM_SPI=y ++CONFIG_MTK_SPI_NAND=y ++CONFIG_MTK_SPI_NAND_MTD=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_WDT_MTK=y ++CONFIG_LZO=y ++CONFIG_ZSTD=y ++CONFIG_HEXDUMP=y ++CONFIG_RANDOM_UUID=y ++CONFIG_REGEX=y ++CONFIG_USB=y ++CONFIG_USB_HOST=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_XHCI_MTK=y ++CONFIG_USB_STORAGE=y ++CONFIG_OF_EMBED=y ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_ENV_OFFSET=0x400000 ++CONFIG_ENV_OFFSET_REDUND=0x440000 ++CONFIG_ENV_SIZE=0x40000 ++CONFIG_ENV_SIZE_REDUND=0x40000 ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_PHY_FIXED=y ++CONFIG_DM_ETH=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7988=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTK_SPIM=y ++#CONFIG_MTK_SNOR=y ++CONFIG_DM_SPI_FLASH=y ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set ++CONFIG_CMD_SF=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_NAND_TRIMFFS=y ++CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_SERVERIP=y ++CONFIG_SERVERIP="192.168.1.254" +--- /dev/null ++++ b/configs/mt7988a_bananapi_bpi-r4-snand_defconfig +@@ -0,0 +1,182 @@ ++CONFIG_ARM=y ++CONFIG_SYS_HAS_NONCACHED_MEMORY=y ++CONFIG_POSITION_INDEPENDENT=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_TEXT_BASE=0x41e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_SYS_PROMPT="MT7988> " ++CONFIG_TARGET_MT7988=y ++CONFIG_DEBUG_UART_BASE=0x11000000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_SYS_LOAD_ADDR=0x50000000 ++CONFIG_DEBUG_UART=y ++CONFIG_SYS_CBSIZE=512 ++CONFIG_SYS_PBSIZE=1049 ++CONFIG_DEFAULT_DEVICE_TREE="mt7988a-bananapi-bpi-r4-emmc" ++CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r4_snand_env" ++CONFIG_DEFAULT_FDT_FILE="mediatek/mt7988a-bpi-r4-emmc.dtb" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_OF_SYSTEM_SETUP=y ++CONFIG_SMBIOS_PRODUCT_NAME="" ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_BOOTDELAY=30 ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_CFB_CONSOLE_ANSI=y ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_GPIO_HOG=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_FIT=y ++CONFIG_FIT_ENABLE_SHA256_SUPPORT=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_LOGLEVEL=7 ++CONFIG_LOG=y ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_BOOTP=y ++CONFIG_CMD_BUTTON=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_ECHO=y ++CONFIG_CMD_ENV_READMEM=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FDT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_ITEST=y ++CONFIG_CMD_LED=y ++CONFIG_CMD_LICENSE=y ++CONFIG_CMD_LINK_LOCAL=y ++# CONFIG_CMD_MBR is not set ++CONFIG_CMD_MMC=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_PWM=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_TFTPBOOT=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++CONFIG_CMD_UBIFS=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_SETEXPR=y ++CONFIG_CMD_SLEEP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_SOURCE=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_UUID=y ++CONFIG_DISPLAY_CPUINFO=y ++CONFIG_DM_MMC=y ++CONFIG_DM_MTD=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_USB=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_REDUNDAND_ENVIRONMENT=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_PARTITION_UUIDS=y ++CONFIG_NETCONSOLE=y ++CONFIG_DM_GPIO=y ++CONFIG_DM_SCSI=y ++CONFIG_AHCI=y ++CONFIG_AHCI_PCI=y ++CONFIG_SCSI_AHCI=y ++CONFIG_SCSI=y ++CONFIG_CMD_SCSI=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_MTK_AHCI=y ++CONFIG_PCI=y ++CONFIG_MTD=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_DM_PCI=y ++CONFIG_PCIE_MEDIATEK=y ++CONFIG_PINCTRL_MT7988=y ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00 ++CONFIG_RAM=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_MMC=y ++CONFIG_MMC_DEFAULT_DEV=1 ++CONFIG_MMC_SUPPORTS_TUNING=y ++CONFIG_SPI=y ++CONFIG_DM_SPI=y ++CONFIG_MTK_SPI_NAND=y ++CONFIG_MTK_SPI_NAND_MTD=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_WDT_MTK=y ++CONFIG_LZO=y ++CONFIG_ZSTD=y ++CONFIG_HEXDUMP=y ++CONFIG_RANDOM_UUID=y ++CONFIG_REGEX=y ++CONFIG_USB=y ++CONFIG_USB_HOST=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_XHCI_MTK=y ++CONFIG_USB_STORAGE=y ++CONFIG_OF_EMBED=y ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_UBI=y ++CONFIG_ENV_UBI_PART="ubi" ++CONFIG_ENV_SIZE=0x1f000 ++CONFIG_ENV_SIZE_REDUND=0x1f000 ++CONFIG_ENV_UBI_VOLUME="ubootenv" ++CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2" ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS200_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_PHY_FIXED=y ++CONFIG_DM_ETH=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7988=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_USE_DEFAULT_ENV_FILE=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTK_SPIM=y ++#CONFIG_MTK_SNOR=y ++CONFIG_DM_SPI_FLASH=y ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_SPI_FLASH_WINBOND=y ++# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set ++CONFIG_CMD_SF=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_NAND_TRIMFFS=y ++CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_SERVERIP=y ++CONFIG_SERVERIP="192.168.1.254" +--- /dev/null ++++ b/bananapi_bpi-r4_sdmmc_env +@@ -0,0 +1,66 @@ ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x50000000 ++bootargs=console=ttyS0,115200n1 pci=pcie_bus_perf root=/dev/fit0 ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_sdmmc ; fi ++bootconf=config-mt7988a-bananapi-bpi-r4 ++bootconf_sd=mt7988a-bananapi-bpi-r4-sd ++bootconf_emmc=mt7988a-bananapi-bpi-r4-emmc ++bootconf_extra= ++bootdelay=0 ++bootfile=openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb ++bootfile_upg=openwrt-mediatek-filogic-bananapi_bpi-r4-squashfs-sysupgrade.itb ++bootled_pwr=green:status ++bootled_rec=blue:status ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) [SD card] ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot production system from SD card.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from SD card.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to SD card.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to SD card.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Install bootloader, recovery and production to NAND.=if nand info ; then run ubi_init ; else echo "NAND not detected" ; fi ; run bootmenu_confirm_return ++bootmenu_7=Reboot.=reset ++bootmenu_8=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=led $bootled_pwr on ; run sdmmc_read_production && bootm $loadaddr#$bootconf#$bootconf_sd#$bootconf_extra ; led $bootled_pwr off ++boot_recovery=led $bootled_rec on ; run sdmmc_read_recovery && bootm $loadaddr#$bootconf#$bootconf_emmc ; led $bootled_rec off ++boot_sdmmc=run boot_production ; run boot_recovery ++boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run sdmmc_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_sd#$bootconf_extra ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run sdmmc_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_sd ; fi ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf#$bootconf_sd ++mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size ++mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200 ++part_default=production ++part_recovery=recovery ++reset_factory=eraseenv && reset ++sdmmc_read_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_read_vol ++sdmmc_read_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_read_vol ++sdmmc_read_snand_bl2=part start mmc 0 install part_addr && mmc read $loadaddr $part_addr 0x400 ++sdmmc_read_snand_fip=part start mmc 0 install part_addr && setexpr offset $part_addr + 0x800 && mmc read $loadaddr $offset 0x1000 ++sdmmc_read_emmc_install=part start mmc 0 install part_addr && setexpr offset $part_addr + 0x3800 && mmc read $loadaddr $offset 0x4000 ++sdmmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol ++sdmmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x80000 && mtd write bl2 $loadaddr 0x80000 0x80000 && mtd write bl2 $loadaddr 0x100000 0x80000 && mtd write bl2 $loadaddr 0x180000 0x80000 ++ubi_create_env=ubi create ubootenv 0x100000 dynamic 1 ; ubi create ubootenv2 0x100000 dynamic 2 ++ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ++ubi_init=run ubi_format && run ubi_init_bl && run ubi_create_env && run ubi_init_openwrt && run ubi_init_emmc_install ++ubi_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run ubi_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run ubi_write_production ++ubi_init_bl=run sdmmc_read_snand_bl2 && run snand_write_bl2 && run sdmmc_read_snand_fip && run ubi_write_fip ++ubi_init_emmc_install=run sdmmc_read_emmc_install && run ubi_write_emmc_install ++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi ++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_emmc_install=ubi check emmc_install && ubi remove emmc_install ; ubi create emmc_install 0x800000 dynamic ; ubi write $loadaddr emmc_install 0x800000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize ++_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/bananapi_bpi-r4_snand_env +@@ -0,0 +1,67 @@ ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x50000000 ++bootargs=console=ttyS0,115200n1 pci=pcie_bus_perf root=/dev/fit0 ubi.block=0,fit ++bootconf=config-mt7988a-bananapi-bpi-r4 ++bootconf_extra=mt7988a-bananapi-bpi-r4-emmc ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi ++bootdelay=0 ++bootfile=openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb ++bootfile_bl2=openwrt-mediatek-filogic-bananapi_bpi-r4-snand-preloader.bin ++bootfile_fip=openwrt-mediatek-filogic-bananapi_bpi-r4-snand-bl31-uboot.fip ++bootfile_upg=openwrt-mediatek-filogic-bananapi_bpi-r4-squashfs-sysupgrade.itb ++bootled_pwr=green:status ++bootled_rec=blue:status ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) [SPI-NAND] ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return ++bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return ++bootmenu_8=Install bootloader, recovery and production to eMMC.=if mmc partconf 0 ; then run emmc_init ; else echo "eMMC not detected" ; fi ; run bootmenu_confirm_return ++bootmenu_9=Reboot.=reset ++bootmenu_10=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf#$bootconf_extra ; led $bootled_pwr off ++boot_recovery=led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off ++boot_ubi=run boot_production ; run boot_recovery ++boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_extra ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++part_default=production ++part_recovery=recovery ++reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800 ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x80000 && mtd write bl2 $loadaddr 0x80000 0x80000 && mtd write bl2 $loadaddr 0x100000 0x80000 && mtd write bl2 $loadaddr 0x180000 0x80000 ++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic 1 ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic 2 ++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi ++ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs ++ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery ++ubi_read_emmc_install=ubi check emmc_install && ubi read $loadaddr emmc_install ++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize ++mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size ++emmc_init=mmc dev 0 && mmc bootbus 0 0 0 0 && run emmc_init_bl && run emmc_init_openwrt ; env default bootcmd ; saveenv ; saveenv ++emmc_init_bl=run ubi_read_emmc_install && setenv fileaddr $loadaddr && run emmc_write_bl2 && setexpr fileaddr $loadaddr + 0x100000 && run emmc_write_fip && setexpr fileaddr $loadaddr + 0x500000 && run emmc_write_hdr ++emmc_init_openwrt=run ubi_read_recovery && iminfo $loadaddr && run emmc_write_recovery ; run ubi_read_production && iminfo $loadaddr && run emmc_write_production ++emmc_write_bl2=mmc partconf 0 1 1 1 && mmc erase 0x0 0x400 && mmc write $fileaddr 0x0 0x400 ; mmc partconf 0 1 1 0 ++emmc_write_fip=mmc erase 0x3400 0x2000 && mmc write $fileaddr 0x3400 0x2000 && mmc erase 0x2000 0x800 ++emmc_write_hdr=mmc erase 0x0 0x40 && mmc write $fileaddr 0x0 0x40 ++emmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol ++emmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol ++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/bananapi_bpi-r4_emmc_env +@@ -0,0 +1,57 @@ ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x50000000 ++bootargs=console=ttyS0,115200n1 pci=pcie_bus_perf root=/dev/fit0 ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi ++bootconf=config-mt7988a-bananapi-bpi-r4 ++bootconf_base=config-mt7988a-bananapi-bpi-r4 ++bootconf_emmc=mt7988a-bananapi-bpi-r4-emmc ++bootconf_extra= ++bootdelay=0 ++bootfile=openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb ++bootfile_bl2=openwrt-mediatek-filogic-bananapi_bpi-r4-emmc-preloader.bin ++bootfile_fip=openwrt-mediatek-filogic-bananapi_bpi-r4-emmc-bl31-uboot.fip ++bootfile_upg=openwrt-mediatek-filogic-bananapi_bpi-r4-squashfs-sysupgrade.itb ++bootled_pwr=green:status ++bootled_rec=blue:status ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=0 ++bootmenu_title= ( ( ( OpenWrt ) ) ) [eMMC] ++bootmenu_0=Initialize environment.=run _firstboot ++bootmenu_0d=Run default boot command.=run boot_default ++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return ++bootmenu_2=Boot production system from eMMC.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from eMMC.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to eMMC.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to eMMC.=run boot_tftp_write_fip ; run bootmenu_confirm_return ++bootmenu_7=Load BL2 preloader via TFTP then write to eMMC.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return ++bootmenu_8=Reboot.=reset ++bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra ; led $bootled_pwr off ++boot_recovery=led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra ; led $bootled_rec off ++boot_emmc=run boot_production ; run boot_recovery ++boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run emmc_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run emmc_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf#$bootconf_emmc ; fi ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run emmc_write_fip ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run emmc_write_bl2 ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf ++mmc_write_vol=imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc erase 0x$part_addr 0x$image_size && mmc write $loadaddr 0x$part_addr 0x$image_size ++mmc_read_vol=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr 0x$part_addr 0x$image_size && setexpr filesize $image_size * 0x200 ++part_default=production ++part_recovery=recovery ++reset_factory=eraseenv && reset ++emmc_read_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_read_vol ++emmc_read_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_read_vol ++emmc_write_bl2=mmc partconf 0 1 1 1 && mmc erase 0x0 0x400 && mmc write $fileaddr 0x0 0x400 ; mmc partconf 0 1 1 0 ++emmc_write_fip=mmc erase 0x3400 0x2000 && mmc write $fileaddr 0x3400 0x2000 && mmc erase 0x2000 0x800 ++emmc_write_production=part start mmc 0 $part_default part_addr && part size mmc 0 $part_default part_size && run mmc_write_vol ++emmc_write_recovery=part start mmc 0 $part_recovery part_addr && part size mmc 0 $part_recovery part_size && run mmc_write_vol ++_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first ++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title ++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +--- /dev/null ++++ b/arch/arm/dts/mt7988a-bananapi-bpi-r4.dtsi +@@ -0,0 +1,199 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2022 MediaTek Inc. ++ * Author: Sam Shih ++ */ ++ ++/dts-v1/; ++#include "mt7988.dtsi" ++#include ++#include ++ ++/ { ++ model = "Bananapi BPI-R4"; ++ compatible = "bananapi,bpi-r4", "mediatek,mt7988"; ++ ++ chosen { ++ stdout-path = &uart0; ++ }; ++ ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0 0x40000000 0 0x10000000>; ++ }; ++ ++ reg_3p3v: regulator-3p3v { ++ compatible = "regulator-fixed"; ++ regulator-name = "fixed-3.3V"; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-boot-on; ++ regulator-always-on; ++ }; ++ ++ reg_1p8v: regulator-1p8v { ++ compatible = "regulator-fixed"; ++ regulator-name = "fixed-1.8V"; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <1800000>; ++ regulator-boot-on; ++ regulator-always-on; ++ }; ++ ++ keys { ++ compatible = "gpio-keys"; ++ ++ wps { ++ label = "reset"; ++ linux,code = ; ++ gpios = <&gpio 14 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led_status_green: led-green { ++ label = "green:status"; ++ gpios = <&gpio 79 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ led_status_blue: led-blue { ++ label = "blue:status"; ++ gpios = <&gpio 63 GPIO_ACTIVE_HIGH>; ++ }; ++ }; ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins>; ++ status = "okay"; ++}; ++ ++ð { ++ status = "okay"; ++ mediatek,gmac-id = <0>; ++ phy-mode = "usxgmii"; ++ mediatek,switch = "mt7988"; ++ ++ fixed-link { ++ speed = <1000>; ++ full-duplex; ++ pause; ++ }; ++}; ++ ++&pinctrl { ++ i2c1_pins: i2c1-pins { ++ mux { ++ function = "i2c"; ++ groups = "i2c1_0"; ++ }; ++ }; ++ ++ pwm_pins: pwm-pins { ++ mux { ++ function = "pwm"; ++ groups = "pwm0", "pwm1", "pwm2", "pwm3", "pwm4", ++ "pwm5", "pwm6", "pwm7"; ++ }; ++ }; ++ ++ spi0_pins: spi0-pins { ++ mux { ++ function = "spi"; ++ groups = "spi0", "spi0_wp_hold"; ++ }; ++ }; ++ ++ mmc0_pins_default: mmc0default { ++ mux { ++ function = "flash"; ++ groups = "emmc_51"; ++ }; ++ ++ conf-cmd-dat { ++ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2", ++ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5", ++ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD"; ++ input-enable; ++ }; ++ ++ conf-clk { ++ pins = "EMMC_CK"; ++ }; ++ ++ conf-dsl { ++ pins = "EMMC_DSL"; ++ }; ++ ++ conf-rst { ++ pins = "EMMC_RSTB"; ++ }; ++ }; ++ ++ mmc1_pins_default: mmc1default { ++ mux { ++ function = "flash"; ++ groups = "emmc_45"; ++ }; ++ ++ conf-cmd-dat { ++ pins = "SPI2_CSB", "SPI2_MISO", "SPI2_MOSI", ++ "SPI2_CLK", "SPI2_HOLD"; ++ input-enable; ++ }; ++ ++ conf-clk { ++ pins = "SPI2_WP"; ++ }; ++ }; ++}; ++ ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm_pins>; ++ status = "okay"; ++}; ++ ++&spi0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&spi0_pins>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ must_tx; ++ enhance_timing; ++ dma_ext; ++ ipm_design; ++ support_quad; ++ tick_dly = <2>; ++ sample_sel = <0>; ++ ++ spi_nand@0 { ++ compatible = "spi-nand"; ++ reg = <0>; ++ spi-max-frequency = <52000000>; ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "bl2"; ++ reg = <0x0 0x200000>; ++ }; ++ ++ partition@200000 { ++ label = "ubi"; ++ reg = <0x200000 0x7e00000>; ++ compatible = "linux,ubi"; ++ }; ++ }; ++ }; ++}; +--- /dev/null ++++ b/arch/arm/dts/mt7988a-bananapi-bpi-r4-sd.dts +@@ -0,0 +1,19 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2022 MediaTek Inc. ++ * Author: Sam Shih ++ */ ++ ++/dts-v1/; ++#include "mt7988a-bananapi-bpi-r4.dtsi" ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc1_pins_default>; ++ max-frequency = <52000000>; ++ bus-width = <4>; ++ cap-sd-highspeed; ++ vmmc-supply = <®_3p3v>; ++ vqmmc-supply = <®_3p3v>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/arm/dts/mt7988a-bananapi-bpi-r4-emmc.dts +@@ -0,0 +1,21 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2022 MediaTek Inc. ++ * Author: Sam Shih ++ */ ++ ++/dts-v1/; ++#include "mt7988a-bananapi-bpi-r4.dtsi" ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_default>; ++ max-frequency = <52000000>; ++ bus-width = <8>; ++ cap-mmc-highspeed; ++ cap-mmc-hw-reset; ++ vmmc-supply = <®_3p3v>; ++ vqmmc-supply = <®_1p8v>; ++ non-removable; ++ status = "okay"; ++}; diff --git a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch b/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch deleted file mode 100644 index 2f0ed85e53f22d..00000000000000 --- a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/board/mediatek/mt7623/mt7623_rfb.c -+++ b/board/mediatek/mt7623/mt7623_rfb.c -@@ -9,6 +9,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -31,8 +32,9 @@ int mmc_get_boot_dev(void) - { - int g_mmc_devid = -1; - char *uflag = (char *)0x81DFFFF0; -+ struct blk_desc *desc; - -- if (!find_mmc_device(1)) -+ if (blk_get_device_by_str("mmc", "1", &desc) < 0) - return 0; - - if (strncmp(uflag,"eMMC",4)==0) { diff --git a/package/boot/uboot-rockchip/Makefile b/package/boot/uboot-rockchip/Makefile index 71eac09d98ba39..c9b3bbd3ac1f2a 100644 --- a/package/boot/uboot-rockchip/Makefile +++ b/package/boot/uboot-rockchip/Makefile @@ -39,6 +39,13 @@ define U-Boot/nanopi-r2c-rk3328 friendlyarm_nanopi-r2c endef +define U-Boot/nanopi-r2c-plus-rk3328 + $(U-Boot/rk3328/Default) + NAME:=NanoPi R2C Plus + BUILD_DEVICES:= \ + friendlyarm_nanopi-r2c-plus +endef + define U-Boot/nanopi-r2s-rk3328 $(U-Boot/rk3328/Default) NAME:=NanoPi R2S @@ -100,7 +107,8 @@ define U-Boot/nanopi-r4s-rk3399 $(U-Boot/rk3399/Default) NAME:=NanoPi R4S BUILD_DEVICES:= \ - friendlyarm_nanopi-r4s + friendlyarm_nanopi-r4s \ + friendlyarm_nanopi-r4s-enterprise endef define U-Boot/rock-pi-4-rk3399 @@ -118,6 +126,22 @@ define U-Boot/rockpro64-rk3399 endef +# RK3566 boards + +define U-Boot/rk3566/Default + BUILD_SUBTARGET:=armv8 + DEPENDS:=+PACKAGE_u-boot-$(1):trusted-firmware-a-rk3566 + ATF:=rk3568_bl31_v1.43.elf + TPL:=rk3566_ddr_1056MHz_v1.18.bin +endef + +define U-Boot/radxa-cm3-io-rk3566 + $(U-Boot/rk3566/Default) + NAME:=CM3 IO + BUILD_DEVICES:= \ + radxa_cm3-io +endef + # RK3568 boards define U-Boot/rk3568/Default @@ -147,12 +171,14 @@ UBOOT_TARGETS := \ rock-pi-4-rk3399 \ rockpro64-rk3399 \ nanopi-r2c-rk3328 \ + nanopi-r2c-plus-rk3328 \ nanopi-r2s-rk3328 \ orangepi-r1-plus-rk3328 \ orangepi-r1-plus-lts-rk3328 \ roc-cc-rk3328 \ rock64-rk3328 \ rock-pi-e-rk3328 \ + radxa-cm3-io-rk3566 \ nanopi-r5c-rk3568 \ nanopi-r5s-rk3568 @@ -164,7 +190,6 @@ UBOOT_CUSTOMIZE_CONFIG := \ --set-str MKIMAGE_DTC_PATH $(PKG_BUILD_DIR)/scripts/dtc/dtc UBOOT_MAKE_FLAGS += \ - PATH=$(STAGING_DIR_HOST)/bin:$(PATH) \ BL31=$(STAGING_DIR_IMAGE)/$(ATF) \ $(if $(TPL),ROCKCHIP_TPL=$(STAGING_DIR_IMAGE)/$(TPL)) diff --git a/package/boot/uboot-rockchip/patches/001-board-rockchip-Add-support-for-FriendlyARM-NanoPi-R2C-Plu.patch b/package/boot/uboot-rockchip/patches/001-board-rockchip-Add-support-for-FriendlyARM-NanoPi-R2C-Plu.patch new file mode 100644 index 00000000000000..25e063bfa98c94 --- /dev/null +++ b/package/boot/uboot-rockchip/patches/001-board-rockchip-Add-support-for-FriendlyARM-NanoPi-R2C-Plu.patch @@ -0,0 +1,213 @@ +From 0bc16c6a8744a1c0293a31253020205b312895d3 Mon Sep 17 00:00:00 2001 +From: Tianling Shen +Date: Sat, 23 Dec 2023 12:00:07 +0800 +Subject: [PATCH] board: rockchip: Add support for FriendlyARM NanoPi R2C Plus + +The NanoPi R2C Plus is a small variant of NanoPi R2C with a on-board +eMMC flash (8G) included. + +The device tree is taken from the kernel v6.5. + +Signed-off-by: Tianling Shen +Reviewed-by: Kever Yang +--- + arch/arm/dts/Makefile | 1 + + .../dts/rk3328-nanopi-r2c-plus-u-boot.dtsi | 9 ++ + arch/arm/dts/rk3328-nanopi-r2c-plus.dts | 33 +++++ + board/rockchip/evb_rk3328/MAINTAINERS | 6 + + configs/nanopi-r2c-plus-rk3328_defconfig | 114 ++++++++++++++++++ + 5 files changed, 163 insertions(+) + create mode 100644 arch/arm/dts/rk3328-nanopi-r2c-plus-u-boot.dtsi + create mode 100644 arch/arm/dts/rk3328-nanopi-r2c-plus.dts + create mode 100644 configs/nanopi-r2c-plus-rk3328_defconfig + +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -126,6 +126,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3308) += \ + dtb-$(CONFIG_ROCKCHIP_RK3328) += \ + rk3328-evb.dtb \ + rk3328-nanopi-r2c.dtb \ ++ rk3328-nanopi-r2c-plus.dtb \ + rk3328-nanopi-r2s.dtb \ + rk3328-orangepi-r1-plus.dtb \ + rk3328-orangepi-r1-plus-lts.dtb \ +--- /dev/null ++++ b/arch/arm/dts/rk3328-nanopi-r2c-plus-u-boot.dtsi +@@ -0,0 +1,9 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++#include "rk3328-nanopi-r2c-u-boot.dtsi" ++ ++/ { ++ chosen { ++ u-boot,spl-boot-order = "same-as-spl", &sdmmc, &emmc; ++ }; ++}; +--- /dev/null ++++ b/arch/arm/dts/rk3328-nanopi-r2c-plus.dts +@@ -0,0 +1,33 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT ++/* ++ * Copyright (c) 2021 FriendlyElec Computer Tech. Co., Ltd. ++ * (http://www.friendlyarm.com) ++ * ++ * Copyright (c) 2023 Tianling Shen ++ */ ++ ++/dts-v1/; ++#include "rk3328-nanopi-r2c.dts" ++ ++/ { ++ model = "FriendlyElec NanoPi R2C Plus"; ++ compatible = "friendlyarm,nanopi-r2c-plus", "rockchip,rk3328"; ++ ++ aliases { ++ mmc1 = &emmc; ++ }; ++}; ++ ++&emmc { ++ bus-width = <8>; ++ cap-mmc-highspeed; ++ max-frequency = <150000000>; ++ mmc-ddr-1_8v; ++ mmc-hs200-1_8v; ++ non-removable; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_bus8>; ++ vmmc-supply = <&vcc_io_33>; ++ vqmmc-supply = <&vcc18_emmc>; ++ status = "okay"; ++}; +--- a/board/rockchip/evb_rk3328/MAINTAINERS ++++ b/board/rockchip/evb_rk3328/MAINTAINERS +@@ -11,6 +11,12 @@ S: Maintained + F: configs/nanopi-r2c-rk3328_defconfig + F: arch/arm/dts/rk3328-nanopi-r2c-u-boot.dtsi + ++NANOPI-R2C-PLUS-RK3328 ++M: Tianling Shen ++S: Maintained ++F: configs/nanopi-r2c-plus-rk3328_defconfig ++F: arch/arm/dts/rk3328-nanopi-r2c-plus-u-boot.dtsi ++ + NANOPI-R2S-RK3328 + M: David Bauer + S: Maintained +--- /dev/null ++++ b/configs/nanopi-r2c-plus-rk3328_defconfig +@@ -0,0 +1,114 @@ ++CONFIG_ARM=y ++CONFIG_SKIP_LOWLEVEL_INIT=y ++CONFIG_COUNTER_FREQUENCY=24000000 ++CONFIG_ARCH_ROCKCHIP=y ++CONFIG_TEXT_BASE=0x00200000 ++CONFIG_SPL_GPIO=y ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y ++CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x300000 ++CONFIG_SF_DEFAULT_SPEED=20000000 ++CONFIG_ENV_OFFSET=0x3F8000 ++CONFIG_DEFAULT_DEVICE_TREE="rk3328-nanopi-r2c-plus" ++CONFIG_DM_RESET=y ++CONFIG_ROCKCHIP_RK3328=y ++CONFIG_TPL_ROCKCHIP_COMMON_BOARD=y ++CONFIG_TPL_LIBCOMMON_SUPPORT=y ++CONFIG_TPL_LIBGENERIC_SUPPORT=y ++CONFIG_SPL_DRIVERS_MISC=y ++CONFIG_SPL_STACK_R_ADDR=0x600000 ++CONFIG_SPL_STACK=0x400000 ++CONFIG_TPL_SYS_MALLOC_F_LEN=0x800 ++CONFIG_DEBUG_UART_BASE=0xFF130000 ++CONFIG_DEBUG_UART_CLOCK=24000000 ++CONFIG_SYS_LOAD_ADDR=0x800800 ++CONFIG_DEBUG_UART=y ++# CONFIG_ANDROID_BOOT_IMAGE is not set ++CONFIG_FIT=y ++CONFIG_FIT_VERBOSE=y ++CONFIG_SPL_LOAD_FIT=y ++CONFIG_DEFAULT_FDT_FILE="rockchip/rk3328-nanopi-r2c-plus.dtb" ++# CONFIG_DISPLAY_CPUINFO is not set ++CONFIG_DISPLAY_BOARDINFO_LATE=y ++CONFIG_MISC_INIT_R=y ++CONFIG_SPL_MAX_SIZE=0x40000 ++CONFIG_SPL_PAD_TO=0x7f8000 ++CONFIG_SPL_HAS_BSS_LINKER_SECTION=y ++CONFIG_SPL_BSS_START_ADDR=0x2000000 ++CONFIG_SPL_BSS_MAX_SIZE=0x2000 ++# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set ++# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set ++CONFIG_SPL_STACK_R=y ++CONFIG_SPL_I2C=y ++CONFIG_SPL_POWER=y ++CONFIG_SPL_ATF=y ++CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y ++CONFIG_TPL_SYS_MALLOC_SIMPLE=y ++CONFIG_CMD_BOOTZ=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_MMC=y ++CONFIG_CMD_USB=y ++# CONFIG_CMD_SETEXPR is not set ++CONFIG_CMD_TIME=y ++CONFIG_SPL_OF_CONTROL=y ++CONFIG_TPL_OF_CONTROL=y ++CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" ++CONFIG_TPL_OF_PLATDATA=y ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_SYS_MMC_ENV_DEV=1 ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_TPL_DM=y ++CONFIG_REGMAP=y ++CONFIG_SPL_REGMAP=y ++CONFIG_TPL_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_SPL_SYSCON=y ++CONFIG_TPL_SYSCON=y ++CONFIG_CLK=y ++CONFIG_SPL_CLK=y ++CONFIG_FASTBOOT_BUF_ADDR=0x800800 ++CONFIG_FASTBOOT_CMD_OEM_FORMAT=y ++CONFIG_ROCKCHIP_GPIO=y ++CONFIG_SYS_I2C_ROCKCHIP=y ++CONFIG_MISC=y ++CONFIG_MMC_DW=y ++CONFIG_MMC_DW_ROCKCHIP=y ++CONFIG_ETH_DESIGNWARE=y ++CONFIG_GMAC_ROCKCHIP=y ++CONFIG_PHY_ROCKCHIP_INNO_USB2=y ++CONFIG_PINCTRL=y ++CONFIG_SPL_PINCTRL=y ++CONFIG_DM_PMIC=y ++CONFIG_PMIC_RK8XX=y ++CONFIG_SPL_PMIC_RK8XX=y ++CONFIG_SPL_DM_REGULATOR=y ++CONFIG_REGULATOR_PWM=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_SPL_DM_REGULATOR_FIXED=y ++CONFIG_REGULATOR_RK8XX=y ++CONFIG_PWM_ROCKCHIP=y ++CONFIG_RAM=y ++CONFIG_SPL_RAM=y ++CONFIG_TPL_RAM=y ++CONFIG_BAUDRATE=1500000 ++CONFIG_DEBUG_UART_SHIFT=2 ++CONFIG_SYS_NS16550_MEM32=y ++CONFIG_SYSINFO=y ++CONFIG_SYSRESET=y ++# CONFIG_TPL_SYSRESET is not set ++CONFIG_USB=y ++CONFIG_USB_XHCI_HCD=y ++CONFIG_USB_EHCI_HCD=y ++CONFIG_USB_EHCI_GENERIC=y ++CONFIG_USB_OHCI_HCD=y ++CONFIG_USB_OHCI_GENERIC=y ++CONFIG_USB_DWC2=y ++CONFIG_USB_DWC3=y ++# CONFIG_USB_DWC3_GADGET is not set ++CONFIG_USB_DWC3_GENERIC=y ++CONFIG_USB_GADGET=y ++CONFIG_USB_GADGET_DWC2_OTG=y ++CONFIG_SPL_TINY_MEMSET=y ++CONFIG_TPL_TINY_MEMSET=y ++CONFIG_ERRNO_STR=y diff --git a/package/devel/binutils/Makefile b/package/devel/binutils/Makefile index 3a54a0be92c672..3fb281c2edd3b5 100644 --- a/package/devel/binutils/Makefile +++ b/package/devel/binutils/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=binutils -PKG_VERSION:=2.41 +PKG_VERSION:=2.42 PKG_RELEASE:=1 PKG_SOURCE_URL:=@GNU/binutils PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_VERSION:=$(PKG_VERSION) -PKG_HASH:=ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450 +PKG_HASH:=f6e4d41fd5fc778b06b7891457b3620da5ecea1006c6a4a41ae998109f85a800 PKG_FIXUP:=patch-libtool PKG_LIBTOOL_PATHS:=. gas bfd opcodes gprof gprofng binutils ld libiberty gold intl libctf libsframe diff --git a/package/devel/binutils/patches/001-replace-attribute_const.patch b/package/devel/binutils/patches/001-replace-attribute_const.patch index 5fd855efd16423..dac641de110e80 100644 --- a/package/devel/binutils/patches/001-replace-attribute_const.patch +++ b/package/devel/binutils/patches/001-replace-attribute_const.patch @@ -28,8 +28,8 @@ unwind.c:490:3: note: in expansion of macro 'FILL_CONTEXT' unsigned int *ecx ATTRIBUTE_UNUSED, unsigned int *edx ATTRIBUTE_UNUSED) --- a/gprofng/libcollector/unwind.c +++ b/gprofng/libcollector/unwind.c -@@ -233,7 +233,7 @@ memory_error_func (int status ATTRIBUTE_ - #elif ARCH(Aarch64) +@@ -237,7 +237,7 @@ typedef uint64_t __u64; + #define FILL_CONTEXT(context) \ { CALL_UTIL (getcontext) (context); \ - context->uc_mcontext.sp = (__u64) __builtin_frame_address(0); \ @@ -37,7 +37,7 @@ unwind.c:490:3: note: in expansion of macro 'FILL_CONTEXT' } #endif /* ARCH() */ -@@ -4579,11 +4579,11 @@ stack_unwind (char *buf, int size, void +@@ -4583,11 +4583,11 @@ stack_unwind (char *buf, int size, void if (buf && bptr && eptr && context && size + mode > 0) getByteInstruction ((unsigned char *) eptr); int ind = 0; @@ -54,7 +54,7 @@ unwind.c:490:3: note: in expansion of macro 'FILL_CONTEXT' unsigned long tbgn = 0; unsigned long tend = 0; -@@ -4594,7 +4594,7 @@ stack_unwind (char *buf, int size, void +@@ -4598,7 +4598,7 @@ stack_unwind (char *buf, int size, void { stack_base = sp + 0x100000; if (stack_base < sp) // overflow @@ -63,7 +63,7 @@ unwind.c:490:3: note: in expansion of macro 'FILL_CONTEXT' } DprintfT (SP_DUMP_UNWIND, "unwind.c:%d stack_unwind %2d pc=0x%llx sp=0x%llx stack_base=0x%llx\n", -@@ -4625,17 +4625,17 @@ stack_unwind (char *buf, int size, void +@@ -4629,17 +4629,17 @@ stack_unwind (char *buf, int size, void __LINE__, (unsigned long) sp); break; } diff --git a/package/devel/strace/Makefile b/package/devel/strace/Makefile index 8ff0ead807c78f..c4c395566b82a2 100644 --- a/package/devel/strace/Makefile +++ b/package/devel/strace/Makefile @@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=strace -PKG_VERSION:=6.6 +PKG_VERSION:=6.7 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION) -PKG_HASH:=421b4186c06b705163e64dc85f271ebdcf67660af8667283147d5e859fc8a96c +PKG_HASH:=2090201e1a3ff32846f4fe421c1163b15f440bb38e31355d09f82d3949922af7 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=LGPL-2.1-or-later diff --git a/package/firmware/ath11k-firmware/Makefile b/package/firmware/ath11k-firmware/Makefile index ea4977aa68ca1e..384595f10d07c9 100644 --- a/package/firmware/ath11k-firmware/Makefile +++ b/package/firmware/ath11k-firmware/Makefile @@ -11,7 +11,7 @@ PKG_NAME:=ath11k-firmware PKG_SOURCE_DATE:=2023-08-22 PKG_SOURCE_VERSION:=d8f82a98ff1aef330d65d8b5660b46d1a9809ee3 PKG_MIRROR_HASH:=3dba19449758c3b17f117990d7ad4086554e012b579f1de16e9d9196a7fbaaa7 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/quic/upstream-wifi-fw.git @@ -32,6 +32,11 @@ define Package/ath11k-firmware-default DEPENDS:= endef +define Package/ath11k-firmware-ipq6018 +$(Package/ath11k-firmware-default) + TITLE:=IPQ6018 ath11k firmware +endef + define Package/ath11k-firmware-ipq8074 $(Package/ath11k-firmware-default) TITLE:=IPQ8074 ath11k firmware @@ -57,6 +62,28 @@ define Download/qcn9074-board endef $(eval $(call Download,qcn9074-board)) +define Download/ath11k-firmware-old + URL:=https://github.com/kvalo/ath11k-firmware.git + VERSION:=540105aa5c0903b5f773d4e80b8501e8da5217e7 + PROTO:=git + FILE:=ath11k-firmware-old.tar.xz + SUBDIR:=ath11k-firmware-old + MIRROR_HASH:=a35a164726fab2adc4ad447c974c06746355ba74deab9b849d39f06b5187bb6d +endef +$(eval $(call Download,ath11k-firmware-old)) + +define Build/Prepare + $(call Build/Prepare/Default) + xzcat $(DL_DIR)/ath11k-firmware-old.tar.xz | tar -C $(PKG_BUILD_DIR)/ -xf - +endef + +define Package/ath11k-firmware-ipq6018/install + $(INSTALL_DIR) $(1)/lib/firmware/IPQ6018 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/ath11k-firmware-old/IPQ6018/hw1.0/2.4.0.1/WLAN.HK.2.4.0.1-01746-QCAHKSWPL_SILICONZ-1/* \ + $(1)/lib/firmware/IPQ6018/ +endef + define Package/ath11k-firmware-ipq8074/install $(INSTALL_DIR) $(1)/lib/firmware/IPQ8074 $(INSTALL_DATA) \ @@ -73,5 +100,6 @@ define Package/ath11k-firmware-qcn9074/install $(DL_DIR)/$(QCN9074_BOARD_FILE) $(1)/lib/firmware/ath11k/QCN9074/hw1.0/board-2.bin endef +$(eval $(call BuildPackage,ath11k-firmware-ipq6018)) $(eval $(call BuildPackage,ath11k-firmware-ipq8074)) $(eval $(call BuildPackage,ath11k-firmware-qcn9074)) diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index 5806654ecfb676..0da6b58b2c167b 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -6,9 +6,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware/qca-wireless.git -PKG_SOURCE_DATE:=2024-01-06 -PKG_SOURCE_VERSION:=71f45cff8944405b7cc2bf5c19df2bd8fe7f2421 -PKG_MIRROR_HASH:=90c3c1659c54cdb4685d0a71633746c1000230e459801eb8ce12c805a994cc37 +PKG_SOURCE_DATE:=2024-02-25 +PKG_SOURCE_VERSION:=fc30aeeb8ec5d069710a446f4eb5e30fc26145c1 +PKG_MIRROR_HASH:=7fe83e3f36541444e0385a56fa8a048772d0531e16787cc10bce29775c7db235 PKG_FLAGS:=nonshared @@ -28,13 +28,17 @@ endef # ALLWIFIBOARDS:= \ + 8devices_mango \ arcadyan_aw1000 \ buffalo_wxr-5950ax12 \ + cmcc_rm2-6 \ compex_wpq873 \ dynalink_dl-wrx36 \ edgecore_eap102 \ edimax_cax1800 \ linksys_mx4200 \ + linksys_mx5300 \ + netgear_lbr20 \ netgear_rax120v2 \ netgear_wax218 \ netgear_wax620 \ @@ -84,12 +88,14 @@ define ipq-wifi-install-one $(call ipq-wifi-install-one-to,$(1),$(2),QCA9984/hw1.0),\ $(if $(filter $(suffix $(1)),.QCA99X0 .qca99x0),\ $(call ipq-wifi-install-one-to,$(1),$(2),QCA99X0/hw2.0),\ - $(if $(filter $(suffix $(1)),.IPQ8074 .ipq8074 .ipq8174),\ + $(if $(filter $(suffix $(1)),.IPQ6018 .ipq6018),\ + $(call ipq-wifi-install-ath11-one-to,$(1),$(2),IPQ6018/hw1.0),\ + $(if $(filter $(suffix $(1)),.IPQ8074 .ipq8074),\ $(call ipq-wifi-install-ath11-one-to,$(1),$(2),IPQ8074/hw2.0),\ $(if $(filter $(suffix $(1)),.QCN9074 .qcn9074),\ $(call ipq-wifi-install-ath11-one-to,$(1),$(2),QCN9074/hw1.0),\ $(error Unrecognized board-file suffix '$(suffix $(1))' for '$(1)')\ - ))))))) + )))))))) endef # Blank line required at end of above define due to foreach context @@ -139,13 +145,17 @@ endef # Board files should follow this name structure: # board-. +$(eval $(call generate-ipq-wifi-package,8devices_mango,8devices Mango)) $(eval $(call generate-ipq-wifi-package,arcadyan_aw1000,Arcadyan AW1000)) $(eval $(call generate-ipq-wifi-package,buffalo_wxr-5950ax12,Buffalo WXR-5950AX12)) +$(eval $(call generate-ipq-wifi-package,cmcc_rm2-6,CMCC RM2-6)) $(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873)) $(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36)) $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102)) $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800)) $(eval $(call generate-ipq-wifi-package,linksys_mx4200,Linksys MX4200)) +$(eval $(call generate-ipq-wifi-package,linksys_mx5300,Linksys MX5300)) +$(eval $(call generate-ipq-wifi-package,netgear_lbr20,Netgear LBR20)) $(eval $(call generate-ipq-wifi-package,netgear_rax120v2,Netgear RAX120v2)) $(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218)) $(eval $(call generate-ipq-wifi-package,netgear_wax620,Netgear WAX620)) diff --git a/package/firmware/layerscape/ls-dpl/Makefile b/package/firmware/layerscape/ls-dpl/Makefile index 6c53b4541700fa..7ceba620bb9538 100644 --- a/package/firmware/layerscape/ls-dpl/Makefile +++ b/package/firmware/layerscape/ls-dpl/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ls-dpl -PKG_VERSION:=21.08 -PKG_RELEASE:=3 +PKG_VERSION:=10.38.0 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/nxp-qoriq/mc-utils -PKG_SOURCE_VERSION:=LSDK-21.08 -PKG_MIRROR_HASH:=372498ff4b5c8a1ac64ead5856d03ee021332f57771989ed6fe066745372b242 +PKG_SOURCE_VERSION:=mc_release_10.38.0 +PKG_MIRROR_HASH:=c5032ad73a04cf7fa23a2afeee85108677e665871a6c48ca352f415eea9b6390 PKG_FLAGS:=nonshared diff --git a/package/firmware/layerscape/ls-mc/Makefile b/package/firmware/layerscape/ls-mc/Makefile index 49cdfdc0625790..3ef5a783272cb3 100644 --- a/package/firmware/layerscape/ls-mc/Makefile +++ b/package/firmware/layerscape/ls-mc/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ls-mc -PKG_VERSION:=21.08 -PKG_RELEASE:=3 +PKG_VERSION:=10.38.0 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/NXP/qoriq-mc-binary.git -PKG_SOURCE_VERSION:=LSDK-21.08 -PKG_MIRROR_HASH:=ab22c16b2bce37886c15ffeed7b068e5b46d619eae58e5a6a005028f5ddb06b6 +PKG_SOURCE_VERSION:=mc_release_10.38.0 +PKG_MIRROR_HASH:=b4482690246f9bd6a8728c482fd391ccf9b25a104b02f08add6e5c5d43a5ad75 PKG_FLAGS:=nonshared @@ -32,11 +32,11 @@ endef define Build/InstallDev $(INSTALL_DIR) $(STAGING_DIR_IMAGE) - $(CP) $(PKG_BUILD_DIR)/ls1088a/mc_ls1088a_10.28.1.itb \ + $(CP) $(PKG_BUILD_DIR)/ls1088a/mc_ls1088a_$(PKG_VERSION).itb \ $(STAGING_DIR_IMAGE)/fsl_ls1088a-rdb-mc.itb - $(CP) $(PKG_BUILD_DIR)/ls2088a/mc_ls2088a_10.28.1.itb \ + $(CP) $(PKG_BUILD_DIR)/ls2088a/mc_ls2088a_$(PKG_VERSION).itb \ $(STAGING_DIR_IMAGE)/fsl_ls2088a-rdb-mc.itb - $(CP) $(PKG_BUILD_DIR)/lx216xa/mc_lx2160a_10.28.1.itb \ + $(CP) $(PKG_BUILD_DIR)/lx216xa/mc_lx2160a_$(PKG_VERSION).itb \ $(STAGING_DIR_IMAGE)/fsl_lx2160a-rdb-mc.itb endef diff --git a/package/firmware/linux-firmware/airoha.mk b/package/firmware/linux-firmware/airoha.mk new file mode 100644 index 00000000000000..ac64d11e41c03b --- /dev/null +++ b/package/firmware/linux-firmware/airoha.mk @@ -0,0 +1,17 @@ +Package/airoha-en8811h-firmware = $(call Package/firmware-default,Airoha EN8811H 2.5G Ethernet PHY firmware) +define Package/airoha-en8811h-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/airoha + $(CP) \ + $(PKG_BUILD_DIR)/airoha/EthMD32.dm.bin \ + $(PKG_BUILD_DIR)/airoha/EthMD32.DSP.bin \ + $(1)/lib/firmware/airoha +ifneq ($(CONFIG_TARGET_mediatek_filogic),) + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + cat \ + $(PKG_BUILD_DIR)/airoha/EthMD32.dm.bin \ + $(PKG_BUILD_DIR)/airoha/EthMD32.DSP.bin \ + > $(STAGING_DIR_IMAGE)/EthMD32.bin +endif +endef + +$(eval $(call BuildPackage,airoha-en8811h-firmware)) diff --git a/package/firmware/linux-firmware/intel.mk b/package/firmware/linux-firmware/intel.mk index 27b0d8ce64c456..19a96b2c85a09e 100644 --- a/package/firmware/linux-firmware/intel.mk +++ b/package/firmware/linux-firmware/intel.mk @@ -192,6 +192,14 @@ define Package/iwlwifi-firmware-ax210/install endef $(eval $(call BuildPackage,iwlwifi-firmware-ax210)) +Package/iwlwifi-firmware-be200 = $(call Package/firmware-default,Intel BE200 firmware) +define Package/iwlwifi-firmware-be200/install + $(INSTALL_DIR) $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/iwlwifi-gl-c0-fm-c0-83.ucode $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/iwlwifi-gl-c0-fm-c0.pnvm $(1)/lib/firmware +endef +$(eval $(call BuildPackage,iwlwifi-firmware-be200)) + Package/e100-firmware = $(call Package/firmware-default,Intel e100) define Package/e100-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/e100 diff --git a/package/firmware/linux-firmware/mediatek.mk b/package/firmware/linux-firmware/mediatek.mk index a0eccb8f4d5811..bf6bef22a6416c 100644 --- a/package/firmware/linux-firmware/mediatek.mk +++ b/package/firmware/linux-firmware/mediatek.mk @@ -87,3 +87,12 @@ define Package/mt7986-wo-firmware/install $(1)/lib/firmware/mediatek endef $(eval $(call BuildPackage,mt7986-wo-firmware)) + +Package/mt7988-2p5g-phy-firmware = $(call Package/firmware-default,MT7988 built-in 2.5G Ethernet PHY firmware) +define Package/mt7988-2p5g-phy-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7988 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/mediatek/mt7988/i2p5ge-phy-pmb.bin \ + $(1)/lib/firmware/mediatek/mt7988 +endef +$(eval $(call BuildPackage,mt7988-2p5g-phy-firmware)) diff --git a/package/firmware/wireless-regdb/Makefile b/package/firmware/wireless-regdb/Makefile index dfff35ff4d7edc..431d07c35b8cac 100644 --- a/package/firmware/wireless-regdb/Makefile +++ b/package/firmware/wireless-regdb/Makefile @@ -1,12 +1,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wireless-regdb -PKG_VERSION:=2023.09.01 +PKG_VERSION:=2024.01.23 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/software/network/wireless-regdb/ -PKG_HASH:=26d4c2a727cc59239b84735aad856b7c7d0b04e30aa5c235c4f7f47f5f053491 +PKG_HASH:=c8a61c9acf76fa7eb4239e89f640dee3e87098d9f69b4d3518c9c60fc6d20c55 PKG_MAINTAINER:=Felix Fietkau @@ -16,7 +16,7 @@ define Package/wireless-regdb PKGARCH:=all SECTION:=firmware CATEGORY:=Firmware - URL:=https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/ + URL:=https://git.kernel.org/pub/scm/linux/kernel/git/wens/wireless-regdb.git/ TITLE:=Wireless Regulatory Database endef diff --git a/package/kernel/broadcom-wl/Makefile b/package/kernel/broadcom-wl/Makefile deleted file mode 100644 index a1feacbe2901a4..00000000000000 --- a/package/kernel/broadcom-wl/Makefile +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright (C) 2006-2014 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk -include $(INCLUDE_DIR)/kernel.mk - -PKG_NAME:=broadcom-wl -PKG_VERSION:=5.10.56.27.3 -PKG_RELEASE:=10 - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2 -PKG_SOURCE_URL:=@OPENWRT - -ifeq ($(ARCH),mipsel) -PKG_HASH:=26a8c370f48fc129d0731cfd751c36cae1419b0bc8ca35781126744e60eae009 -endif -ifeq ($(ARCH),mips) -PKG_HASH:=ca6a86ca3e3e9c85b6dbb665b35bcbf338c37829c1b2f1994487d55664886045 -endif - -PKG_EXTMOD_SUBDIRS:=driver driver-mini glue - -PKG_BUILD_FLAGS:=no-mips16 -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/broadcom-wl/Default - SECTION:=kernel - CATEGORY:=Kernel modules - DEPENDS:=@(PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini) - SUBMENU:=Proprietary BCM43xx WiFi driver - SUBMENUDEP:=(TARGET_bcm47xx||TARGET_bcm63xx) -endef - -define KernelPackage/brcm-wl/Default - $(call Package/broadcom-wl/Default) - SECTION:=kernel - DEPENDS:=@(TARGET_bcm47xx||TARGET_bcm63xx) +wireless-tools +@KERNEL_WIRELESS_EXT - TITLE:=Kernel driver for BCM43xx chipsets - FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko - AUTOLOAD:=$(call AutoProbe,wl) -endef - -define KernelPackage/brcm-wl/Default/description - This package contains the proprietary wireless driver for the Broadcom - BCM43xx chipset. -endef - -define KernelPackage/brcm-wl -$(call KernelPackage/brcm-wl/Default,) - TITLE+= (normal version) -endef - -define KernelPackage/brcm-wl/description -$(call KernelPackage/brcm-wl/Default/description) -endef - -define KernelPackage/brcm-wl-mini -$(call KernelPackage/brcm-wl/Default,-mini) - TITLE+= (Legacy version) -endef - -define KernelPackage/brcm-wl-mini/description -$(call KernelPackage/brcm-wl/Default/description) -endef - -define Package/wlc -$(call Package/broadcom-wl/Default) - TITLE:=wl driver setup utility -endef - -define Package/wlc/description - This package contains an utility for initializing the proprietary Broadcom - wl driver. -endef - -define Package/wl -$(call Package/broadcom-wl/Default) - TITLE:=Proprietary Broadcom wl driver config utility -endef - -define Package/wl/description - This package contains the proprietary utility (wl) for configuring the - proprietary Broadcom wl driver. -endef - -define Package/nas -$(call Package/broadcom-wl/Default) - TITLE:=Proprietary Broadcom WPA/WPA2 authenticator -endef - -define Package/nas/description - This package contains the proprietary WPA/WPA2 authenticator (nas) for the - proprietary Broadcom wl driver. -endef - -MAKE_KMOD := $(KERNEL_MAKE) \ - PATH="$(TARGET_PATH)" \ - M="$(PKG_BUILD_DIR)/kmod" \ - -define Build/Prepare - $(call Build/Prepare/Default) - - # New kernel version changed the sysmbol exported from printk to _printk - # The object file provided by broadcom require modification to correctly - # modprobe and generate a .ko - $(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta/wl_prebuilt.o \ - --redefine-sym printk=_printk - $(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta_mini/wl_prebuilt.o \ - --redefine-sym printk=_printk - - $(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini - $(CP) ./src/glue $(PKG_BUILD_DIR)/glue -endef - -define Build/Compile - # Compile glue driver - $(MAKE_KMOD) -C "$(LINUX_DIR)" \ - M="$(PKG_BUILD_DIR)/glue" \ - modules - - # Compile the kernel part - $(MAKE_KMOD) \ - M="$(PKG_BUILD_DIR)/driver" \ - MODFLAGS="-DMODULE -mlong-calls" \ - KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \ - modules - - $(MAKE_KMOD) \ - M="$(PKG_BUILD_DIR)/driver-mini" \ - MODFLAGS="-DMODULE -mlong-calls" \ - BUILD_TYPE="wl_apsta_mini" \ - KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \ - modules - - # Compile libshared - $(MAKE) -C $(PKG_BUILD_DIR)/shared \ - $(TARGET_CONFIGURE_OPTS) \ - CFLAGS="$(TARGET_CFLAGS) -I. -I$(PKG_BUILD_DIR)/driver/include" \ - all - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/wlc \ - -I$(PKG_BUILD_DIR)/shared -I$(PKG_BUILD_DIR)/driver/include \ - ./src/wlc.c $(PKG_BUILD_DIR)/shared/libshared.a - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/nas \ - $(PKG_BUILD_DIR)/nas_exe.o \ - $(PKG_BUILD_DIR)/shared/libshared.a - - $(TARGET_CC) -o $(PKG_BUILD_DIR)/wl \ - $(PKG_BUILD_DIR)/wl_exe.o \ - $(PKG_BUILD_DIR)/shared/libshared.a -endef - -define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_BUILD_DIR)/shared/libshared.a $(1)/usr/lib/ -endef - -define Package/wlc/install - $(CP) ./files/* $(1)/ - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/wlc $(1)/sbin/ -endef - -define Package/wlc/postinst -#!/bin/sh -[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/wlunbind enable || true -endef - -define Package/wl/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/ -endef - -define Package/nas/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/ - $(LN) nas $(1)/usr/sbin/nas4not - $(LN) nas $(1)/usr/sbin/nas4wds -endef - -$(eval $(call KernelPackage,brcm-wl)) -$(eval $(call KernelPackage,brcm-wl-mini)) -$(eval $(call BuildPackage,wlc)) -$(eval $(call BuildPackage,wl)) -$(eval $(call BuildPackage,nas)) diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect deleted file mode 100644 index a63d6bce60fb60..00000000000000 --- a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -[ "${ACTION}" = "add" ] && [ "${INTERFACE%%[0-9]}" = "wl" ] && { - /sbin/wifi config -} diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds deleted file mode 100644 index 35c4218e03a966..00000000000000 --- a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds +++ /dev/null @@ -1,61 +0,0 @@ -include /lib/wifi - -setup_broadcom_wds() { - local iface="$1" - local remote="$(wlc ifname "$iface" wdsmac)" - - [ -z "$remote" ] && return - - config_cb() { - [ -z "$CONFIG_SECTION" ] && return - - config_get type "$CONFIG_SECTION" TYPE - [ "$type" = "wifi-iface" ] || return - - config_get network "$CONFIG_SECTION" network - [ -z "$network" ] && return - - config_get addr "$CONFIG_SECTION" bssid - addr=$(echo "$addr" | tr 'A-F' 'a-f') - [ "$addr" = "$remote" ] && { - local cfg="$CONFIG_SECTION" - - include /lib/network - scan_interfaces - - for network in $network; do - setup_interface "$iface" "$network" - done - - config_get encryption "$cfg" encryption - config_get key "$cfg" key - config_get ssid "$cfg" ssid - - [ "$encryption" != "none" ] && { - sleep 5 - case "$encryption" in - psk|PSK) - nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid" - ;; - psk2|PSK2) - nas4not "$network" "$iface" up auto aes psk "$key" "$ssid" - ;; - psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK) - nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid" - ;; - *) - nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid" - ;; - esac - } - } - } - - config_load wireless -} - -case "$ACTION" in - add|register) - [ "${INTERFACE%%[0-1]-*}" = wds ] && setup_broadcom_wds "$INTERFACE" - ;; -esac diff --git a/package/kernel/broadcom-wl/files/etc/init.d/wlunbind b/package/kernel/broadcom-wl/files/etc/init.d/wlunbind deleted file mode 100755 index 0a29db565fb91e..00000000000000 --- a/package/kernel/broadcom-wl/files/etc/init.d/wlunbind +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2010-2011 OpenWrt.org - -START=09 - -unbind_driver() { - local driver="$1" - local sysfs="/sys/bus/pci/drivers/$driver" - if [ -d "$sysfs" ]; then - local lnk - for lnk in $sysfs/*; do - [ -h "$lnk" ] || continue - case "${lnk##*/}" in - *:*:*.*) - logger "Unbinding WL PCI device ${lnk##*/} from $driver" - echo -n "${lnk##*/}" > "$sysfs/unbind" - ;; - esac - done - fi -} - -boot() { - unbind_driver b43-pci-bridge - unbind_driver bcma-pci-bridge -} - -start() { :; } -stop() { :; } diff --git a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh deleted file mode 100644 index 352c365f275217..00000000000000 --- a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh +++ /dev/null @@ -1,480 +0,0 @@ -append DRIVERS "broadcom" - -scan_broadcom() { - local device="$1" - local vif vifs wds - local adhoc sta apmode mon disabled - local adhoc_if sta_if ap_if mon_if - - config_get vifs "$device" vifs - for vif in $vifs; do - config_get_bool disabled "$vif" disabled 0 - [ $disabled -eq 0 ] || continue - - local mode - config_get mode "$vif" mode - case "$mode" in - adhoc) - adhoc=1 - adhoc_if="$vif" - ;; - sta) - sta=1 - sta_if="$vif" - ;; - ap) - apmode=1 - ap_if="${ap_if:+$ap_if }$vif" - ;; - wds) - local addr - config_get addr "$vif" bssid - [ -z "$addr" ] || { - addr=$(echo "$addr" | tr 'A-F' 'a-f') - append wds "$addr" - } - ;; - monitor) - mon=1 - mon_if="$vif" - ;; - *) echo "$device($vif): Invalid mode";; - esac - done - config_set "$device" wds "$wds" - - local _c= - for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do - config_set "$vif" ifname "${device}${_c:+-$_c}" - _c=$((${_c:-0} + 1)) - done - config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}" - - ap=1 - infra=1 - if [ "$_c" -gt 1 ]; then - mssid=1 - else - mssid= - fi - apsta=0 - radio=1 - monitor=0 - case "$adhoc:$sta:$apmode:$mon" in - 1*) - ap=0 - mssid= - infra=0 - ;; - :1:1:) - apsta=1 - wet=1 - ;; - :1::) - wet=1 - ap=0 - mssid= - ;; - :::1) - wet=1 - ap=0 - mssid= - monitor=1 - ;; - ::) - radio=0 - ;; - esac -} - -disable_broadcom() { - local device="$1" - set_wifi_down "$device" - ( - include /lib/network - - local pid_file=/var/run/nas.$device.pid - [ -e $pid_file ] && start-stop-daemon -K -q -s SIGKILL -p $pid_file && rm $pid_file - - # make sure the interfaces are down and removed from all bridges - local dev ifname - for dev in /sys/class/net/wds${device##wl}-* /sys/class/net/${device}-* /sys/class/net/${device}; do - if [ -e "$dev" ]; then - ifname=${dev##/sys/class/net/} - ip link set dev "$ifname" down - unbridge "$ifname" - fi - done - - # make sure all of the devices are disabled in the driver - local ifdown= - local bssmax=$(wlc ifname "$device" bssmax) - local vif=$((${bssmax:-4} - 1)) - append ifdown "down" "$N" - append ifdown "wds none" "$N" - while [ $vif -ge 0 ]; do - append ifdown "vif $vif" "$N" - append ifdown "enabled 0" "$N" - vif=$(($vif - 1)) - done - - wlc ifname "$device" stdin <