mirror of
				https://github.com/Ysurac/openmptcprouter.git
				synced 2025-03-09 15:40:20 +00:00 
			
		
		
		
	Add patches and packages needed for BPI-r2
This commit is contained in:
		
							parent
							
								
									b105e79652
								
							
						
					
					
						commit
						3406c7d37b
					
				
					 165 changed files with 241259 additions and 29 deletions
				
			
		
							
								
								
									
										60
									
								
								root/package/kernel/mt6625l-wlan-gen2/Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								root/package/kernel/mt6625l-wlan-gen2/Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,60 @@ | |||
| #
 | ||||
| # Copyright (C) 2014-2016 OpenWrt.org
 | ||||
| #
 | ||||
| # This is free software, licensed under the GNU General Public License v2.
 | ||||
| # See /LICENSE for more information.
 | ||||
| #
 | ||||
| 
 | ||||
| include $(TOPDIR)/rules.mk | ||||
| 
 | ||||
| PKG_NAME:=mt6625l-wlan-gen2 | ||||
| PKG_RELEASE:=1 | ||||
| 
 | ||||
| PKG_SOURCE_PROTO:=git | ||||
| PKG_SOURCE_URL:=https://github.com/abbradar/mt6625l-wlan-gen2 | ||||
| PKG_SOURCE_DATE:=2018-07-05 | ||||
| PKG_SOURCE_VERSION:=d7ed406b7d4d4b608f6416269075281d090ecfd7 | ||||
| PKG_MAINTAINER:=Nikolay Amiantov <ab@fmap.me> | ||||
| 
 | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
| 
 | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
| 
 | ||||
| define KernelPackage/mt6625l-wlan-gen2 | ||||
|   SUBMENU:=Wireless Drivers | ||||
|   TITLE:=Mediatek MT6625L wireless chip support | ||||
|   URL:=http://www.datasheetcafe.com/mt6625l-datasheet-chip-mediatek/ | ||||
|   KCONFIG:= \
 | ||||
|     CONFIG_MTK_WAPI_SUPPORT=y \
 | ||||
|     CONFIG_MTK_PASSPOINT_R1_SUPPORT=y \
 | ||||
|     CONFIG_MTK_PASSPOINT_R2_SUPPORT=y \
 | ||||
|     CONFIG_MTK_WIFI_MCC_SUPPORT=y \
 | ||||
|     CONFIG_MTK_COMBO_WIFI | ||||
|   DEPENDS:=@TARGET_mediatek +kmod-mac80211 +@DRIVER_11N_SUPPORT | ||||
|   FILES:= \
 | ||||
|         $(PKG_BUILD_DIR)/wlan_gen2.ko | ||||
|   AUTOLOAD:=$(call AutoProbe,wlan_gen2) | ||||
| endef | ||||
| 
 | ||||
| define KernelPackage/mt6625l-wlan-gen2/description | ||||
|   Kernel support for Mediatek MT6625L connectivity chip Wi-Fi module | ||||
| endef | ||||
| 
 | ||||
| NOSTDINC_FLAGS = \
 | ||||
| 	-I$(PKG_BUILD_DIR) \
 | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
 | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211-backport \
 | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211/uapi \
 | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211 \
 | ||||
| 	-include backport/backport.h | ||||
| 
 | ||||
| define Build/Compile | ||||
| 	+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
 | ||||
| 		$(KERNEL_MAKE_FLAGS) \
 | ||||
| 		SUBDIRS="$(PKG_BUILD_DIR)" \
 | ||||
| 		NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
 | ||||
| 		modules | ||||
| endef | ||||
| 
 | ||||
| $(eval $(call KernelPackage,mt6625l-wlan-gen2)) | ||||
							
								
								
									
										50
									
								
								root/package/utils/wmt/Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								root/package/utils/wmt/Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| #
 | ||||
| # Copyright (C) 2009 OpenWrt.org
 | ||||
| #
 | ||||
| # This is free software, licensed under the GNU General Public License v2.
 | ||||
| # See /LICENSE for more information.
 | ||||
| #
 | ||||
| 
 | ||||
| include $(TOPDIR)/rules.mk | ||||
| 
 | ||||
| PKG_NAME:=wmt | ||||
| PKG_VERSION:=1.0.0 | ||||
| PKG_RELEASE:=1 | ||||
| 
 | ||||
| PKG_SOURCE_PROTO:=git | ||||
| PKG_SOURCE_URL:=https://github.com/abbradar/wmt | ||||
| PKG_SOURCE_VERSION:=2127e23dd94df960b12f3ffff806bcf41ebbf4b8 | ||||
| PKG_MAINTAINER:=Nikolay Amiantov <ab@fmap.me> | ||||
| 
 | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
| 
 | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
| 
 | ||||
| define Package/$(PKG_NAME) | ||||
|   SECTION:=utils | ||||
|   CATEGORY:=Utilities | ||||
|   TITLE:=wmt utility for MT6625L | ||||
|   DEPENDS:=kmod-mt6625l-wlan-gen2 | ||||
|   MAINTAINER:=Jinkai li <lijk@synertone.net> | ||||
| endef | ||||
| 
 | ||||
| define Package/$(PKG_NAME)/description | ||||
|   Utility for loading MT6625L firmware. | ||||
| endef | ||||
| 
 | ||||
| define Package/$(PKG_NAME)/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/bin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/stp_uart_launcher $(1)/usr/bin/ | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wmt_loader $(1)/usr/bin/ | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wmt_loopback $(1)/usr/bin/ | ||||
| 	$(INSTALL_DIR) $(1)/system/etc/firmware | ||||
| 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/WMT_SOC.cfg $(1)/system/etc/firmware | ||||
| 	$(INSTALL_DIR) $(1)/etc/firmware | ||||
| 	$(CP) -r $(PKG_BUILD_DIR)/firmware/* $(1)/etc/firmware/ | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) ./files/wmt.init $(1)/etc/init.d/wmt | ||||
| 	$(INSTALL_DIR) $(1)/etc/uci-defaults | ||||
| 	$(INSTALL_BIN) ./files/wmt.defaults $(1)/etc/uci-defaults/03wmt | ||||
| endef | ||||
| 
 | ||||
| $(eval $(call BuildPackage,$(PKG_NAME))) | ||||
							
								
								
									
										28
									
								
								root/package/utils/wmt/files/wmt.defaults
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								root/package/utils/wmt/files/wmt.defaults
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| uci batch <<-EOF | ||||
| 	set wireless.mtk_ap=wifi-device | ||||
| 	set wireless.mtk_ap.type=mac80211 | ||||
| 	set wireless.mtk_ap.channel=11 | ||||
| 	set wireless.mtk_ap.hwmode=11g | ||||
| 	set wireless.mtk_ap.phy=mtkp2p0 | ||||
| 	set wireless.mtk_ap.htmode=HT20 | ||||
| 	set wireless.mtk_ap.disabled=1 | ||||
| 
 | ||||
| 	set wireless.mtk_managed=wifi-device | ||||
| 	set wireless.mtk_managed.type=mac80211 | ||||
| 	set wireless.mtk_managed.phy=mtkphy0 | ||||
| 	set wireless.mtk_managed.disabled=1 | ||||
| 
 | ||||
| 	set wireless.default_mtk_ap=wifi-iface | ||||
| 	set wireless.default_mtk_ap.device=mtk_ap | ||||
| 	set wireless.default_mtk_ap.ifname=mtkap0 | ||||
| 	set wireless.default_mtk_ap.bss_load_update_period=0 | ||||
| 	set wireless.default_mtk_ap.network=lan | ||||
| 	set wireless.default_mtk_ap.mode=ap | ||||
| 	set wireless.default_mtk_ap.ssid=OpenWrt | ||||
| 	set wireless.default_mtk_ap.encryption=none | ||||
| 
 | ||||
| 	commit wireless | ||||
| EOF | ||||
| exit 0 | ||||
							
								
								
									
										70
									
								
								root/package/utils/wmt/files/wmt.init
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								root/package/utils/wmt/files/wmt.init
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,70 @@ | |||
| #!/bin/sh /etc/rc.common | ||||
| 
 | ||||
| START=19 | ||||
| 
 | ||||
| check_mtk_device() { | ||||
| 	config_get phy "$1" phy | ||||
| 	[ "$phy" = "mtkp2p0" ] && radiop2p="$1" | ||||
| } | ||||
| 
 | ||||
| find_radio() { | ||||
| 	config_load wireless | ||||
| 	radiop2p="" | ||||
| 	config_foreach check_mtk_device wifi-device | ||||
| } | ||||
| 
 | ||||
| stop_ap() { | ||||
| 	find_radio | ||||
| 	[ -n "$radiop2p" ] && wifi down "$radiop2p" 2>/dev/null | ||||
| 	echo 0 > /dev/wmtWifi | ||||
| } | ||||
| 
 | ||||
| start_ap() { | ||||
| 	echo A > /dev/wmtWifi | ||||
| 	# Those are recommended by vendor to avoid chip lockup. | ||||
| 	tc qdisc add dev mtkap0 root handle 1: htb default 11 | ||||
| 	tc class add dev mtkap0 parent 1:1 classid 1:2 htb rate 8Mbit ceil 4Mbit prio 2 | ||||
| 
 | ||||
| 	find_radio | ||||
| 	if [ -n "$radiop2p" ]; then | ||||
| 		config_get_bool disabled "$radiop2p" disabled | ||||
| 		[ "$disabled" = "1" ] || wifi up "$radiop2p" 2>/dev/null | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| start() { | ||||
| 	find_radio | ||||
| 
 | ||||
| 	[ -c /dev/stpwmt ] || /usr/bin/wmt_loader 2>&1 | ||||
| 	/usr/bin/stp_uart_launcher -p /etc/firmware 2>&1 | logger -t stp_uart_launcher & | ||||
| 	echo "$!" > /var/run/stp_uart_launcher.pid | ||||
| 	sleep 3 | ||||
| 	if [ -c /dev/wmtWifi ]; then | ||||
| 		start_ap | ||||
| 		return 0 | ||||
| 	else | ||||
| 		return 1 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| stop() { | ||||
| 	find_radio | ||||
| 
 | ||||
| 	if [ -c /dev/wmtWifi ]; then | ||||
| 		stop_ap | ||||
| 		stp_pid="$(cat /var/run/stp_uart_launcher.pid 2>/dev/null)" | ||||
| 		if [ -n "$stp_pid" ]; then | ||||
| 			kill "$stp_pid" | ||||
| 			rm /var/run/stp_uart_launcher.pid | ||||
| 		fi | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| reload() { | ||||
| 	find_radio | ||||
| 
 | ||||
| 	if [ -c /dev/wmtWifi ]; then | ||||
| 		stop_ap | ||||
| 		start_ap | ||||
| 	fi | ||||
| } | ||||
							
								
								
									
										43
									
								
								root/target/linux/mediatek/base-files/etc/board.d/02_network
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								root/target/linux/mediatek/base-files/etc/board.d/02_network
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| . /lib/functions.sh | ||||
| . /lib/functions/uci-defaults.sh | ||||
| . /lib/functions/system.sh | ||||
| 
 | ||||
| mediatek_setup_interfaces() | ||||
| { | ||||
| 	local board="$1" | ||||
| 
 | ||||
| 	case $board in | ||||
| 	'mediatek,mt7623a-rfb-emmc') | ||||
| 		ucidef_set_interface_lan "lan0 lan1 lan2 lan3" | ||||
| 		ucidef_set_interface_wan eth1 | ||||
| 		;; | ||||
| 	'bananapi,bpi-r2'|\ | ||||
| 	"unielec,u7623"*) | ||||
| 		ucidef_set_interface_lan "lan" | ||||
| 		ucidef_set_interface_wan "wan1 wan2 wan3 wan4" | ||||
| 		#ucidef_set_interfaces_lan_wan "wan1 wan2 wan3 wan4" "lan" | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
| 
 | ||||
| mediatek_setup_macs() | ||||
| { | ||||
| 	local board="$1" | ||||
| 
 | ||||
| 	case $board in | ||||
| 	"unielec,u7623"*) | ||||
| 		mac=$(cat /sys/class/net/wan/address) | ||||
| 		ucidef_set_interface_macaddr "lan" $mac | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
| 
 | ||||
| board_config_update | ||||
| board=$(board_name) | ||||
| mediatek_setup_interfaces $board | ||||
| mediatek_setup_macs $board | ||||
| board_config_flush | ||||
| 
 | ||||
| exit 0 | ||||
							
								
								
									
										4
									
								
								root/target/linux/mediatek/base-files/etc/inittab
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								root/target/linux/mediatek/base-files/etc/inittab
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | |||
| ::sysinit:/etc/init.d/rcS S boot | ||||
| ::shutdown:/etc/init.d/rcS K shutdown | ||||
| ::askconsole:/usr/libexec/login.sh | ||||
| ttyS0::askfirst:/usr/libexec/login.sh | ||||
							
								
								
									
										6
									
								
								root/target/linux/mediatek/base-files/etc/uci-defaults/99-net-ps
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								root/target/linux/mediatek/base-files/etc/uci-defaults/99-net-ps
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| uci set network.globals.default_rps_val=14 | ||||
| uci set network.globals.default_rps_flow_cnt=256 | ||||
| uci set network.globals.default_xps_val=14 | ||||
| uci set network.globals.default_ps=1 | ||||
| uci commit | ||||
| exit 0 | ||||
|  | @ -0,0 +1,9 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| set_preinit_iface() { | ||||
| 	ifconfig eth0 up | ||||
| 	ifname=lan | ||||
| } | ||||
| 
 | ||||
| boot_hook_add preinit_main set_preinit_iface | ||||
| 
 | ||||
|  | @ -0,0 +1,8 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| set_rps_sock_flow() { | ||||
| 	echo 1024 > /proc/sys/net/core/rps_sock_flow_entries | ||||
| } | ||||
| 
 | ||||
| boot_hook_add preinit_main set_rps_sock_flow | ||||
| 
 | ||||
|  | @ -0,0 +1,48 @@ | |||
| #!/bin/sh | ||||
| # Copyright (C) 2018 OpenWrt.org | ||||
| 
 | ||||
| RECOVERY_PART=/dev/mmcblk0p1 | ||||
| 
 | ||||
| preinit_set_mac_address() { | ||||
| 	local mac | ||||
| 
 | ||||
| 	. /lib/functions.sh | ||||
| 	. /lib/functions/system.sh | ||||
| 
 | ||||
| 	case $(board_name) in | ||||
| 	'bananapi,bpi-r2'|\ | ||||
| 	"unielec,u7623"*) | ||||
| 		if [ -b $RECOVERY_PART ]; then | ||||
| 			insmod nls_cp437 | ||||
| 			insmod nls_iso8859-1 | ||||
| 			insmod fat | ||||
| 			insmod vfat | ||||
| 			mkdir -p /tmp/recovery | ||||
| 			mount -o rw,noatime $RECOVERY_PART /tmp/recovery | ||||
| 
 | ||||
| 			if [ -f "/tmp/recovery/mac_addr" ]; | ||||
| 			then | ||||
| 				mac=$(cat /tmp/recovery/mac_addr) | ||||
| 			else | ||||
| 				mac=$(cat /sys/class/net/eth0/address) | ||||
| 				echo "$mac" > /tmp/recovery/mac_addr | ||||
| 			fi | ||||
| 
 | ||||
| 			sync | ||||
| 			umount /tmp/recovery | ||||
| 			rm -rf /tmp/recovery | ||||
| 		fi | ||||
| 
 | ||||
| 		ip link set dev lan address $mac 2> /dev/null | ||||
| 
 | ||||
| 		mac=$(macaddr_add $mac 1) | ||||
| 
 | ||||
| 		ip link set dev wan1 address $mac 2>/dev/null | ||||
| 		ip link set dev wan2 address $mac 2>/dev/null | ||||
| 		ip link set dev wan3 address $mac 2>/dev/null | ||||
| 		ip link set dev wan4 address $mac 2>/dev/null | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
| 
 | ||||
| boot_hook_add preinit_main preinit_set_mac_address | ||||
|  | @ -0,0 +1,19 @@ | |||
| #!/bin/sh | ||||
| # Copyright (C) 2015 OpenWrt.org | ||||
| 
 | ||||
| RECOVERY_PART=/dev/mmcblk0p1 | ||||
| 
 | ||||
| move_config() { | ||||
| 	if [ -b $RECOVERY_PART ]; then | ||||
| 		insmod nls_cp437 | ||||
| 		insmod nls_iso8859-1 | ||||
| 		insmod fat | ||||
| 		insmod vfat | ||||
| 		mkdir -p /recovery | ||||
| 		mount -o rw,noatime $RECOVERY_PART /recovery | ||||
| 		[ -f /recovery/sysupgrade.tgz ] && mv -f /recovery/sysupgrade.tgz / | ||||
| 		umount /recovery | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| boot_hook_add preinit_mount_root move_config | ||||
							
								
								
									
										85
									
								
								root/target/linux/mediatek/base-files/lib/upgrade/platform.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										85
									
								
								root/target/linux/mediatek/base-files/lib/upgrade/platform.sh
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,85 @@ | |||
| platform_do_upgrade() { | ||||
| 	local board=$(board_name) | ||||
| 	case "$board" in | ||||
| 	"unielec,u7623"*) | ||||
| 		#Keep the persisten random mac address (if it exists) | ||||
| 		mkdir -p /tmp/recovery | ||||
| 		mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery | ||||
| 		[ -f "/tmp/recovery/mac_addr" ] && \ | ||||
| 			mv -f /tmp/recovery/mac_addr /tmp/ | ||||
| 		umount /tmp/recovery | ||||
| 
 | ||||
| 		#1310720 is the offset in bytes from the start of eMMC and to | ||||
| 		#the location of the kernel (2560 512 byte sectors) | ||||
| 		get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync | ||||
| 
 | ||||
| 		mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery | ||||
| 		[ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery | ||||
| 		sync | ||||
| 		umount /tmp/recovery | ||||
| 		;; | ||||
| 	bananapi,bpi-r2) | ||||
| 		local tar_file="$1" | ||||
| 
 | ||||
| 		echo "flashing kernel" | ||||
| 		tar xf $tar_file sysupgrade-7623n-bananapi-bpi-r2/kernel -O | mtd write - kernel | ||||
| 
 | ||||
| 		echo "flashing rootfs" | ||||
| 		tar xf $tar_file sysupgrade-7623n-bananapi-bpi-r2/root -O | mtd write - rootfs | ||||
| 		;; | ||||
| 	*) | ||||
| 		default_do_upgrade "$ARGV" | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
| 
 | ||||
| PART_NAME=firmware | ||||
| 
 | ||||
| platform_check_image() { | ||||
| 	local board=$(board_name) | ||||
| 
 | ||||
| 	[ "$#" -gt 1 ] && return 1 | ||||
| 
 | ||||
| 	case "$board" in | ||||
| 	bananapi,bpi-r2) | ||||
| 		local tar_file="$1" | ||||
| 		local kernel_length=`(tar xf $tar_file sysupgrade-7623n-bananapi-bpi-r2/kernel -O | wc -c) 2> /dev/null` | ||||
| 		local rootfs_length=`(tar xf $tar_file sysupgrade-7623n-bananapi-bpi-r2/root -O | wc -c) 2> /dev/null` | ||||
| 		[ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && { | ||||
| 			echo "The upgrade image is corrupt." | ||||
| 			return 1 | ||||
| 		} | ||||
| 		;; | ||||
| 	"unielec,u7623"*) | ||||
| 		local magic="$(get_magic_long "$1")" | ||||
| 		[ "$magic" != "27051956" ] && { | ||||
| 			echo "Invalid image type." | ||||
| 			return 1 | ||||
| 		} | ||||
| 		return 0 | ||||
| 		;; | ||||
| 
 | ||||
| 	*) | ||||
| 		echo "Sysupgrade is not supported on your board yet." | ||||
| 		return 1 | ||||
| 		;; | ||||
| 	esac | ||||
| 
 | ||||
| 	return 0 | ||||
| } | ||||
| 
 | ||||
| platform_copy_config_emmc() { | ||||
| 	mkdir -p /recovery | ||||
| 	mount -o rw,noatime /dev/mmcblk0p1 /recovery | ||||
| 	cp -af "$CONF_TAR" /recovery/ | ||||
| 	sync | ||||
| 	umount /recovery | ||||
| } | ||||
| 
 | ||||
| platform_copy_config() { | ||||
| 	case "$(board_name)" in | ||||
| 	"unielec,u7623"*) | ||||
| 		platform_copy_config_emmc | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
|  | @ -33,9 +33,12 @@ define Build/sysupgrade-emmc | |||
| endef | ||||
| 
 | ||||
| define Build/sysupgrade-bpi-r2-sd | ||||
|   rm -f $@.recovery | ||||
|   mkfs.fat -C $@.recovery 3070 | ||||
|   dd bs="1024" if="$(STAGING_DIR_IMAGE)/mtk-bpi-r2-preloader-sd.bin" of="$@" seek="0" | ||||
|   dd bs="1024" if="$(STAGING_DIR_IMAGE)/mtk-bpi-r2-uboot.bin" of="$@" seek="320" | ||||
|   dd bs="1024" if="$(IMAGE_KERNEL)" of="$@" seek="2048" | ||||
|   dd bs="1024" if="$@.recovery" of="$@" seek="33792" | ||||
|   dd bs="1024" if="$(IMAGE_ROOTFS)" of="$@" seek="67584" | ||||
| endef | ||||
| define Build/sysupgrade-bpi-r2-emmc | ||||
|  | @ -49,7 +52,7 @@ endef | |||
| define Device/Default | ||||
|   PROFILES = Default $$(DEVICE_NAME) | ||||
|   KERNEL_NAME := zImage | ||||
|   FILESYSTEMS := squashfs | ||||
| #  FILESYSTEMS := squashfs
 | ||||
|   DEVICE_DTS_DIR := $(DTS_DIR) | ||||
|   IMAGES := sysupgrade.bin | ||||
|   IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata  | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ TARGET_DEVICES += 7623a-unielec-u7623-02-emmc-512m | |||
| define Device/7623n-bananapi-bpi-r2 | ||||
|   DEVICE_TITLE := MTK7623n BananaPi R2 | ||||
|   DEVICE_DTS := mt7623n-bananapi-bpi-r2 | ||||
|   DEVICE_PACKAGES += uboot-mtk-bpi_r2 | ||||
|   DEVICE_PACKAGES := wmt uboot-mtk-bpi_r2 | ||||
|   SUPPORTED_DEVICES := bananapi,bpi-r2 | ||||
|   IMAGES := sysupgrade.tar sysupgrade-sd.bin.gz sysupgrade-emmc.bin.gz | ||||
|   IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata | ||||
|  |  | |||
|  | @ -27,7 +27,6 @@ CONFIG_ARCH_SUPPORTS_UPROBES=y | |||
| CONFIG_ARCH_SUSPEND_POSSIBLE=y | ||||
| CONFIG_ARCH_USE_BUILTIN_BSWAP=y | ||||
| CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y | ||||
| # CONFIG_ARCH_WANTS_THP_SWAP is not set | ||||
| CONFIG_ARCH_WANT_GENERAL_HUGETLB=y | ||||
| CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y | ||||
| CONFIG_ARM=y | ||||
|  | @ -52,17 +51,25 @@ CONFIG_ARM_UNWIND=y | |||
| CONFIG_ARM_VIRT_EXT=y | ||||
| CONFIG_ATAGS=y | ||||
| CONFIG_AUTO_ZRELADDR=y | ||||
| CONFIG_BLK_DEV_LOOP=y | ||||
| CONFIG_BLK_MQ_PCI=y | ||||
| CONFIG_BOUNCE=y | ||||
| # CONFIG_CACHE_L2X0 is not set | ||||
| CONFIG_CC_STACKPROTECTOR=y | ||||
| # CONFIG_CC_STACKPROTECTOR_NONE is not set | ||||
| CONFIG_CC_STACKPROTECTOR_REGULAR=y | ||||
| CONFIG_CFG80211=m | ||||
| CONFIG_CFG80211_CRDA_SUPPORT=y | ||||
| # CONFIG_CFG80211_DEBUGFS is not set | ||||
| CONFIG_CFG80211_DEFAULT_PS=y | ||||
| # CONFIG_CFG80211_DEVELOPER_WARNINGS is not set | ||||
| # CONFIG_CFG80211_INTERNAL_REGDB is not set | ||||
| # CONFIG_CFG80211_WEXT is not set | ||||
| CONFIG_CLEANCACHE=y | ||||
| CONFIG_CLKDEV_LOOKUP=y | ||||
| CONFIG_CLKSRC_MMIO=y | ||||
| CONFIG_CLONE_BACKWARDS=y | ||||
| CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,jffs2" | ||||
| CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,ext4,jffs2" | ||||
| CONFIG_CMDLINE_FROM_BOOTLOADER=y | ||||
| CONFIG_COMMON_CLK=y | ||||
| CONFIG_COMMON_CLK_MEDIATEK=y | ||||
|  | @ -73,6 +80,7 @@ CONFIG_COMMON_CLK_MT2701_HIFSYS=y | |||
| CONFIG_COMMON_CLK_MT2701_IMGSYS=y | ||||
| CONFIG_COMMON_CLK_MT2701_MMSYS=y | ||||
| CONFIG_COMMON_CLK_MT2701_VDECSYS=y | ||||
| # CONFIG_COMMON_CLK_MT7622 is not set | ||||
| # CONFIG_COMMON_CLK_MT8135 is not set | ||||
| # CONFIG_COMMON_CLK_MT8173 is not set | ||||
| CONFIG_COMPACTION=y | ||||
|  | @ -114,6 +122,8 @@ CONFIG_CROSS_MEMORY_ATTACH=y | |||
| CONFIG_CRYPTO_ACOMP2=y | ||||
| CONFIG_CRYPTO_AEAD=y | ||||
| CONFIG_CRYPTO_AEAD2=y | ||||
| CONFIG_CRYPTO_CRC32=y | ||||
| CONFIG_CRYPTO_CRC32C=y | ||||
| CONFIG_CRYPTO_CTR=y | ||||
| CONFIG_CRYPTO_DEFLATE=y | ||||
| CONFIG_CRYPTO_DEV_MEDIATEK=y | ||||
|  | @ -157,24 +167,24 @@ CONFIG_DEBUG_UART_PHYS=0x11004000 | |||
| CONFIG_DEBUG_UART_VIRT=0xf1004000 | ||||
| CONFIG_DEBUG_UNCOMPRESS=y | ||||
| # CONFIG_DEBUG_USER is not set | ||||
| CONFIG_DEFAULT_DUMMY=y | ||||
| CONFIG_DEFAULT_SCHEDULER=y | ||||
| CONFIG_DMADEVICES=y | ||||
| CONFIG_DMA_ENGINE=y | ||||
| # CONFIG_DMA_NOOP_OPS is not set | ||||
| CONFIG_DMA_OF=y | ||||
| # CONFIG_DMA_VIRT_OPS is not set | ||||
| # CONFIG_DRM_LIB_RANDOM is not set | ||||
| CONFIG_DTC=y | ||||
| CONFIG_EARLY_PRINTK=y | ||||
| CONFIG_EDAC_ATOMIC_SCRUB=y | ||||
| CONFIG_EDAC_SUPPORT=y | ||||
| CONFIG_ELF_CORE=y | ||||
| CONFIG_EXPORTFS=y | ||||
| CONFIG_EXT4_FS=y | ||||
| # CONFIG_F2FS_CHECK_FS is not set | ||||
| CONFIG_F2FS_FS=y | ||||
| # CONFIG_F2FS_FS_SECURITY is not set | ||||
| CONFIG_F2FS_FS_XATTR=y | ||||
| CONFIG_F2FS_STAT_FS=y | ||||
| CONFIG_FIXED_PHY=y | ||||
| CONFIG_FIX_EARLYCON_MEM=y | ||||
| CONFIG_FREEZER=y | ||||
| CONFIG_FUTEX_PI=y | ||||
| CONFIG_FS_MBCACHE=y | ||||
| CONFIG_GENERIC_ALLOCATOR=y | ||||
| CONFIG_GENERIC_BUG=y | ||||
| CONFIG_GENERIC_CLOCKEVENTS=y | ||||
|  | @ -277,8 +287,8 @@ CONFIG_IRQ_DOMAIN=y | |||
| CONFIG_IRQ_DOMAIN_HIERARCHY=y | ||||
| CONFIG_IRQ_FORCED_THREADING=y | ||||
| CONFIG_IRQ_WORK=y | ||||
| CONFIG_JBD2=y | ||||
| CONFIG_KALLSYMS=y | ||||
| # CONFIG_KEYBOARD_MTK_PMIC is not set | ||||
| CONFIG_LEDS_MT6323=y | ||||
| CONFIG_LIBFDT=y | ||||
| CONFIG_LOCK_SPIN_ON_OWNER=y | ||||
|  | @ -311,11 +321,6 @@ CONFIG_MMC_SDHCI=y | |||
| CONFIG_MMC_SDHCI_PLTFM=y | ||||
| # CONFIG_MMC_TIFM_SD is not set | ||||
| CONFIG_MODULES_USE_ELF_REL=y | ||||
| # CONFIG_MPTCP_BINDER is not set | ||||
| # CONFIG_MPTCP_FULLMESH is not set | ||||
| # CONFIG_MPTCP_NDIFFPORTS is not set | ||||
| # CONFIG_MPTCP_REDUNDANT is not set | ||||
| # CONFIG_MPTCP_ROUNDROBIN is not set | ||||
| CONFIG_MTD_BLOCK2MTD=y | ||||
| CONFIG_MTD_CMDLINE_PARTS=y | ||||
| CONFIG_MTD_M25P80=y | ||||
|  | @ -332,20 +337,45 @@ CONFIG_MTD_UBI_BLOCK=y | |||
| # CONFIG_MTD_UBI_FASTMAP is not set | ||||
| # CONFIG_MTD_UBI_GLUEBI is not set | ||||
| CONFIG_MTD_UBI_WL_THRESHOLD=4096 | ||||
| # CONFIG_MTK_BTIF is not set | ||||
| # CONFIG_MTK_COMBO is not set | ||||
| CONFIG_MTK_BTIF=y | ||||
| CONFIG_MTK_COMBO=y | ||||
| # CONFIG_MTK_COMBO_BT is not set | ||||
| # CONFIG_MTK_COMBO_BT_HCI is not set | ||||
| CONFIG_MTK_COMBO_CHIP="CONSYS_7623" | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6572 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6580 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6582 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6592 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6735 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6752 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6755 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_6797 is not set | ||||
| CONFIG_MTK_COMBO_CHIP_CONSYS_7623=y | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_8127 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_CONSYS_8163 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_MT6620 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_MT6628 is not set | ||||
| # CONFIG_MTK_COMBO_CHIP_MT6630 is not set | ||||
| # CONFIG_MTK_COMBO_COMM is not set | ||||
| CONFIG_MTK_COMBO_PLAT_PATH="" | ||||
| CONFIG_MTK_COMBO_WIFI=m | ||||
| # CONFIG_MTK_CONN_LTE_IDC_SUPPORT is not set | ||||
| # CONFIG_MTK_DHCPV6C_WIFI is not set | ||||
| CONFIG_MTK_DHCPV6C_WIFI=y | ||||
| CONFIG_MTK_EFUSE=y | ||||
| # CONFIG_MTK_GPS_SUPPORT is not set | ||||
| # CONFIG_MTK_HSDMA is not set | ||||
| CONFIG_MTK_INFRACFG=y | ||||
| # CONFIG_MTK_IOMMU is not set | ||||
| # CONFIG_MTK_IOMMU_V1 is not set | ||||
| CONFIG_MTK_PLATFORM="" | ||||
| CONFIG_MTK_PASSPOINT_R1_SUPPORT=y | ||||
| CONFIG_MTK_PASSPOINT_R2_SUPPORT=y | ||||
| CONFIG_MTK_PLATFORM="mt7623" | ||||
| CONFIG_MTK_PMIC_WRAP=y | ||||
| CONFIG_MTK_SCPSYS=y | ||||
| CONFIG_MTK_THERMAL=y | ||||
| CONFIG_MTK_TIMER=y | ||||
| CONFIG_MTK_WAPI_SUPPORT=y | ||||
| CONFIG_MTK_WIFI_MCC_SUPPORT=y | ||||
| CONFIG_MULTI_IRQ_HANDLER=y | ||||
| CONFIG_MUTEX_SPIN_ON_OWNER=y | ||||
| CONFIG_NEED_DMA_MAP_STATE=y | ||||
|  | @ -355,18 +385,17 @@ CONFIG_NET_DSA_MT7530=y | |||
| # CONFIG_NET_DSA_SMSC_LAN9303_I2C is not set | ||||
| CONFIG_NET_DSA_TAG_MTK=y | ||||
| CONFIG_NET_FLOW_LIMIT=y | ||||
| # CONFIG_NET_MEDIATEK_HW_QOS is not set | ||||
| CONFIG_NET_MEDIATEK_SOC=y | ||||
| CONFIG_NET_MEDIATEK_HNAT=y | ||||
| CONFIG_NET_SWITCHDEV=y | ||||
| # CONFIG_NET_VENDOR_AURORA is not set | ||||
| CONFIG_NET_VENDOR_MEDIATEK=y | ||||
| # CONFIG_NET_VENDOR_WIZNET is not set | ||||
| CONFIG_NL80211_TESTMODE=y | ||||
| CONFIG_NLS=y | ||||
| CONFIG_NO_BOOTMEM=y | ||||
| CONFIG_NO_HZ=y | ||||
| CONFIG_NO_HZ_COMMON=y | ||||
| CONFIG_NO_HZ_IDLE=y | ||||
| # CONFIG_NO_HZ is not set | ||||
| # CONFIG_NO_HZ_COMMON is not set | ||||
| # CONFIG_NO_HZ_IDLE is not set | ||||
| CONFIG_NR_CPUS=4 | ||||
| CONFIG_NVMEM=y | ||||
| CONFIG_OF=y | ||||
|  | @ -412,7 +441,6 @@ CONFIG_PM_OPP=y | |||
| CONFIG_PM_SLEEP=y | ||||
| CONFIG_PM_SLEEP_SMP=y | ||||
| CONFIG_POWER_RESET=y | ||||
| # CONFIG_POWER_RESET_MT6323 is not set | ||||
| CONFIG_POWER_SUPPLY=y | ||||
| CONFIG_PREEMPT=y | ||||
| CONFIG_PREEMPT_COUNT=y | ||||
|  | @ -446,7 +474,9 @@ CONFIG_RPS=y | |||
| CONFIG_RTC_CLASS=y | ||||
| # CONFIG_RTC_DRV_CMOS is not set | ||||
| # CONFIG_RTC_DRV_MT6397 is not set | ||||
| # CONFIG_RTC_DRV_MT7622 is not set | ||||
| CONFIG_RTC_I2C_AND_SPI=y | ||||
| # CONFIG_RTL8723BS is not set | ||||
| CONFIG_RWSEM_SPIN_ON_OWNER=y | ||||
| CONFIG_RWSEM_XCHGADD_ALGORITHM=y | ||||
| # CONFIG_SCHED_INFO is not set | ||||
|  | @ -479,7 +509,6 @@ CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y | |||
| CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 | ||||
| CONFIG_THERMAL_GOV_STEP_WISE=y | ||||
| CONFIG_THERMAL_OF=y | ||||
| CONFIG_THIN_ARCHIVES=y | ||||
| # CONFIG_THUMB2_KERNEL is not set | ||||
| CONFIG_TICK_CPU_ACCOUNTING=y | ||||
| CONFIG_TIMER_OF=y | ||||
|  | @ -495,7 +524,8 @@ CONFIG_UNINLINE_SPIN_UNLOCK=y | |||
| CONFIG_USB=y | ||||
| CONFIG_USB_COMMON=y | ||||
| # CONFIG_USB_EHCI_HCD is not set | ||||
| # CONFIG_USB_MTU3 is not set | ||||
| CONFIG_USB_MTU3=y | ||||
| # CONFIG_USB_MTU3_DEBUG is not set | ||||
| CONFIG_USB_SUPPORT=y | ||||
| CONFIG_USB_XHCI_HCD=y | ||||
| CONFIG_USB_XHCI_MTK=y | ||||
|  | @ -506,6 +536,8 @@ CONFIG_VFP=y | |||
| CONFIG_VFPv3=y | ||||
| CONFIG_VM_EVENT_COUNTERS=y | ||||
| CONFIG_WATCHDOG_CORE=y | ||||
| # CONFIG_WILC1000_SDIO is not set | ||||
| # CONFIG_WILC1000_SPI is not set | ||||
| CONFIG_XPS=y | ||||
| CONFIG_XZ_DEC_ARM=y | ||||
| CONFIG_XZ_DEC_BCJ=y | ||||
|  |  | |||
|  | @ -0,0 +1,27 @@ | |||
| From 596c3a7300c0419dba71d58cbd4136e0d1e12a4e Mon Sep 17 00:00:00 2001 | ||||
| From: Shunli Wang <shunli.wang@mediatek.com> | ||||
| Date: Tue, 5 Jan 2016 14:30:22 +0800 | ||||
| Subject: [PATCH 06/57] reset: mediatek: mt2701 reset driver | ||||
| 
 | ||||
| In infrasys and perifsys, there are many reset | ||||
| control bits for kinds of modules. These bits are | ||||
| used as actual reset controllers to be registered | ||||
| into kernel's generic reset controller framework. | ||||
| 
 | ||||
| Signed-off-by: Shunli Wang <shunli.wang@mediatek.com> | ||||
| Acked-by: Philipp Zabel <p.zabel@pengutronix.de> | ||||
| ---
 | ||||
|  drivers/clk/mediatek/clk-mt2701.c | 4 ++++ | ||||
|  1 file changed, 4 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/clk/mediatek/clk-mt2701.c
 | ||||
| +++ b/drivers/clk/mediatek/clk-mt2701.c
 | ||||
| @@ -772,6 +772,8 @@ static void mtk_infrasys_init_early(stru
 | ||||
|  	if (r) | ||||
|  		pr_err("%s(): could not register clock provider: %d\n", | ||||
|  			__func__, r); | ||||
| +
 | ||||
| +	mtk_register_reset_controller(node, 2, 0x30);
 | ||||
|  } | ||||
|  CLK_OF_DECLARE_DRIVER(mtk_infra, "mediatek,mt2701-infracfg", | ||||
|  			mtk_infrasys_init_early); | ||||
|  | @ -0,0 +1,21 @@ | |||
| From 0e60d2112968ccb2570535bf19fb5020c9b28c08 Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <blogic@openwrt.org> | ||||
| Date: Thu, 7 Apr 2016 07:18:35 +0200 | ||||
| Subject: [PATCH 12/57] clk: dont disable unused clocks | ||||
| 
 | ||||
| Signed-off-by: John Crispin <blogic@openwrt.org> | ||||
| ---
 | ||||
|  drivers/clk/clk.c | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/clk/clk.c
 | ||||
| +++ b/drivers/clk/clk.c
 | ||||
| @@ -797,7 +797,7 @@ unlock_out:
 | ||||
|  		clk_core_disable_unprepare(core->parent); | ||||
|  } | ||||
|   | ||||
| -static bool clk_ignore_unused;
 | ||||
| +static bool clk_ignore_unused = true;
 | ||||
|  static int __init clk_ignore_unused_setup(char *__unused) | ||||
|  { | ||||
|  	clk_ignore_unused = true; | ||||
|  | @ -0,0 +1,92 @@ | |||
| From f974e397b806f7b16d11cc1542538616291924f1 Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Sat, 23 Apr 2016 11:57:21 +0200 | ||||
| Subject: [PATCH 27/57] net-next: mediatek: fix DQL support | ||||
| 
 | ||||
| The MTK ethernet core has 2 MACs both sitting on the same DMA ring. The | ||||
| current code will assign the TX traffic of each MAC to its own DQL. This | ||||
| results in the amount of data, that DQL says is in the queue incorrect. As | ||||
| the data from multiple devices is infact enqueued. This makes any decision | ||||
| based on these value non deterministic. Fix this by tracking all TX | ||||
| traffic, regardless of the MAC it belongs to in the DQL of all devices | ||||
| using the DMA. | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 35 +++++++++++++++++------------ | ||||
|  1 file changed, 21 insertions(+), 14 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -779,7 +779,16 @@ static int mtk_tx_map(struct sk_buff *sk
 | ||||
|  	WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | | ||||
|  				(!nr_frags * TX_DMA_LS0))); | ||||
|   | ||||
| -	netdev_sent_queue(dev, skb->len);
 | ||||
| +	/* we have a single DMA ring so BQL needs to be updated for all devices
 | ||||
| +	 * sitting on this ring
 | ||||
| +	 */
 | ||||
| +	for (i = 0; i < MTK_MAC_COUNT; i++) {
 | ||||
| +		if (!eth->netdev[i])
 | ||||
| +			continue;
 | ||||
| +
 | ||||
| +		netdev_sent_queue(eth->netdev[i], skb->len);
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	skb_tx_timestamp(skb); | ||||
|   | ||||
|  	ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2); | ||||
| @@ -1076,20 +1085,17 @@ static int mtk_poll_tx(struct mtk_eth *e
 | ||||
|  	struct mtk_tx_dma *desc; | ||||
|  	struct sk_buff *skb; | ||||
|  	struct mtk_tx_buf *tx_buf; | ||||
| -	unsigned int done[MTK_MAX_DEVS];
 | ||||
| -	unsigned int bytes[MTK_MAX_DEVS];
 | ||||
| +	int total = 0, done = 0;
 | ||||
| +	unsigned int bytes = 0;
 | ||||
|  	u32 cpu, dma; | ||||
| -	int total = 0, i;
 | ||||
| -
 | ||||
| -	memset(done, 0, sizeof(done));
 | ||||
| -	memset(bytes, 0, sizeof(bytes));
 | ||||
| +	int i;
 | ||||
|   | ||||
|  	cpu = mtk_r32(eth, MTK_QTX_CRX_PTR); | ||||
|  	dma = mtk_r32(eth, MTK_QTX_DRX_PTR); | ||||
|   | ||||
|  	desc = mtk_qdma_phys_to_virt(ring, cpu); | ||||
|   | ||||
| -	while ((cpu != dma) && budget) {
 | ||||
| +	while ((cpu != dma) && (done < budget)) {
 | ||||
|  		u32 next_cpu = desc->txd2; | ||||
|  		int mac = 0; | ||||
|   | ||||
| @@ -1106,9 +1112,8 @@ static int mtk_poll_tx(struct mtk_eth *e
 | ||||
|  			break; | ||||
|   | ||||
|  		if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) { | ||||
| -			bytes[mac] += skb->len;
 | ||||
| -			done[mac]++;
 | ||||
| -			budget--;
 | ||||
| +			bytes += skb->len;
 | ||||
| +			done++;
 | ||||
|  		} | ||||
|  		mtk_tx_unmap(eth, tx_buf); | ||||
|   | ||||
| @@ -1120,11 +1125,13 @@ static int mtk_poll_tx(struct mtk_eth *e
 | ||||
|   | ||||
|  	mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); | ||||
|   | ||||
| +	/* we have a single DMA ring so BQL needs to be updated for all devices
 | ||||
| +	 * sitting on this ring
 | ||||
| +	 */
 | ||||
|  	for (i = 0; i < MTK_MAC_COUNT; i++) { | ||||
| -		if (!eth->netdev[i] || !done[i])
 | ||||
| +		if (!eth->netdev[i])
 | ||||
|  			continue; | ||||
| -		netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
 | ||||
| -		total += done[i];
 | ||||
| +		netdev_completed_queue(eth->netdev[i], done, bytes);
 | ||||
|  	} | ||||
|   | ||||
|  	if (mtk_queue_stopped(eth) && | ||||
|  | @ -0,0 +1,26 @@ | |||
| From 52e9ce30a2b3c414e0efb20632fefa7cfc5096e6 Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 14:44:18 +0200 | ||||
| Subject: [PATCH 32/57] net: dsa: mediatek: add support for GMAC2 wired to ext | ||||
|  phy | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/dsa/mt7530.c                    | 5 +++++ | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++ | ||||
|  2 files changed, 8 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/net/dsa/mt7530.c
 | ||||
| +++ b/drivers/net/dsa/mt7530.c
 | ||||
| @@ -991,6 +991,11 @@ mt7530_setup(struct dsa_switch *ds)
 | ||||
|  	val = mt7530_read(priv, MT7530_MHWTRAP); | ||||
|  	val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; | ||||
|  	val |= MHWTRAP_MANUAL; | ||||
| +	if (!dsa_is_cpu_port(ds, 5)) {
 | ||||
| +		val |= MHWTRAP_P5_DIS;
 | ||||
| +		val |= MHWTRAP_P5_MAC_SEL;
 | ||||
| +		val |= MHWTRAP_P5_RGMII_MODE;
 | ||||
| +	}
 | ||||
|  	mt7530_write(priv, MT7530_MHWTRAP, val); | ||||
|   | ||||
|  	/* Enable and reset MIB counters */ | ||||
							
								
								
									
										268
									
								
								root/target/linux/mediatek/patches-4.14/0033-dsa-multi-cpu.patch
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										268
									
								
								root/target/linux/mediatek/patches-4.14/0033-dsa-multi-cpu.patch
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,268 @@ | |||
| --- a/drivers/net/dsa/mt7530.c
 | ||||
| +++ b/drivers/net/dsa/mt7530.c
 | ||||
| @@ -670,6 +670,9 @@ static int
 | ||||
|  mt7530_cpu_port_enable(struct mt7530_priv *priv, | ||||
|  		       int port) | ||||
|  { | ||||
| +	u8 port_mask = 0;
 | ||||
| +	int i;
 | ||||
| +
 | ||||
|  	/* Enable Mediatek header mode on the cpu port */ | ||||
|  	mt7530_write(priv, MT7530_PVC_P(port), | ||||
|  		     PORT_SPEC_TAG); | ||||
| @@ -686,8 +689,12 @@ mt7530_cpu_port_enable(struct mt7530_pri
 | ||||
|  	/* CPU port gets connected to all user ports of | ||||
|  	 * the switch | ||||
|  	 */ | ||||
| +	for (i = 0; i < MT7530_NUM_PORTS; i++)
 | ||||
| +		if ((priv->ds->enabled_port_mask & BIT(i)) &&
 | ||||
| +		    (dsa_port_upstream_port(priv->ds, i) == port))
 | ||||
| +			port_mask |= BIT(i);
 | ||||
|  	mt7530_write(priv, MT7530_PCR_P(port), | ||||
| -		     PCR_MATRIX(priv->ds->enabled_port_mask));
 | ||||
| +		     PCR_MATRIX(port_mask));
 | ||||
|   | ||||
|  	return 0; | ||||
|  } | ||||
| @@ -697,6 +704,7 @@ mt7530_port_enable(struct dsa_switch *ds
 | ||||
|  		   struct phy_device *phy) | ||||
|  { | ||||
|  	struct mt7530_priv *priv = ds->priv; | ||||
| +	u8 upstream = dsa_port_upstream_port(ds, port);
 | ||||
|   | ||||
|  	mutex_lock(&priv->reg_mutex); | ||||
|   | ||||
| @@ -707,7 +715,7 @@ mt7530_port_enable(struct dsa_switch *ds
 | ||||
|  	 * restore the port matrix if the port is the member of a certain | ||||
|  	 * bridge. | ||||
|  	 */ | ||||
| -	priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT));
 | ||||
| +	priv->ports[port].pm |= PCR_MATRIX(BIT(upstream));
 | ||||
|  	priv->ports[port].enable = true; | ||||
|  	mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, | ||||
|  		   priv->ports[port].pm); | ||||
| @@ -770,7 +778,8 @@ mt7530_port_bridge_join(struct dsa_switc
 | ||||
|  			struct net_device *bridge) | ||||
|  { | ||||
|  	struct mt7530_priv *priv = ds->priv; | ||||
| -	u32 port_bitmap = BIT(MT7530_CPU_PORT);
 | ||||
| +	u8 upstream = dsa_port_upstream_port(ds, port);
 | ||||
| +	u32 port_bitmap = BIT(upstream);
 | ||||
|  	int i; | ||||
|   | ||||
|  	mutex_lock(&priv->reg_mutex); | ||||
| @@ -808,6 +817,7 @@ mt7530_port_bridge_leave(struct dsa_swit
 | ||||
|  			 struct net_device *bridge) | ||||
|  { | ||||
|  	struct mt7530_priv *priv = ds->priv; | ||||
| +	u8 upstream = dsa_port_upstream_port(ds, port);
 | ||||
|  	int i; | ||||
|   | ||||
|  	mutex_lock(&priv->reg_mutex); | ||||
| @@ -832,8 +842,8 @@ mt7530_port_bridge_leave(struct dsa_swit
 | ||||
|  	 */ | ||||
|  	if (priv->ports[port].enable) | ||||
|  		mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, | ||||
| -			   PCR_MATRIX(BIT(MT7530_CPU_PORT)));
 | ||||
| -	priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT));
 | ||||
| +			   PCR_MATRIX(BIT(upstream)));
 | ||||
| +	priv->ports[port].pm = PCR_MATRIX(BIT(upstream));
 | ||||
|   | ||||
|  	mutex_unlock(&priv->reg_mutex); | ||||
|  } | ||||
| @@ -908,15 +918,7 @@ err:
 | ||||
|  static enum dsa_tag_protocol | ||||
|  mtk_get_tag_protocol(struct dsa_switch *ds) | ||||
|  { | ||||
| -	struct mt7530_priv *priv = ds->priv;
 | ||||
| -
 | ||||
| -	if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) {
 | ||||
| -		dev_warn(priv->dev,
 | ||||
| -			 "port not matched with tagging CPU port\n");
 | ||||
| -		return DSA_TAG_PROTO_NONE;
 | ||||
| -	} else {
 | ||||
| -		return DSA_TAG_PROTO_MTK;
 | ||||
| -	}
 | ||||
| +	return DSA_TAG_PROTO_MTK;
 | ||||
|  } | ||||
|   | ||||
|  static int | ||||
| @@ -989,7 +991,7 @@ mt7530_setup(struct dsa_switch *ds)
 | ||||
|   | ||||
|  	/* Enable Port 6 only; P5 as GMAC5 which currently is not supported */ | ||||
|  	val = mt7530_read(priv, MT7530_MHWTRAP); | ||||
| -	val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
 | ||||
| +	val &= ~MHWTRAP_P5_DIS & ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
 | ||||
|  	val |= MHWTRAP_MANUAL; | ||||
|  	if (!dsa_is_cpu_port(ds, 5)) { | ||||
|  		val |= MHWTRAP_P5_DIS; | ||||
| --- a/include/net/dsa.h
 | ||||
| +++ b/include/net/dsa.h
 | ||||
| @@ -185,6 +185,10 @@ struct dsa_port {
 | ||||
|  	u8			stp_state; | ||||
|  	struct net_device	*bridge_dev; | ||||
|  	struct devlink_port	devlink_port; | ||||
| +
 | ||||
| +	struct net_device	*ethernet;
 | ||||
| +	int			upstream;
 | ||||
| +
 | ||||
|  	/* | ||||
|  	 * Original copy of the master netdev ethtool_ops | ||||
|  	 */ | ||||
| @@ -266,6 +270,11 @@ static inline bool dsa_is_normal_port(st
 | ||||
|  	return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p); | ||||
|  } | ||||
|   | ||||
| +static inline bool dsa_is_upstream_port(struct dsa_switch *ds, int p)
 | ||||
| +{
 | ||||
| +	return dsa_is_cpu_port(ds, p) || dsa_is_dsa_port(ds, p);
 | ||||
| +}
 | ||||
| +
 | ||||
|  static inline u8 dsa_upstream_port(struct dsa_switch *ds) | ||||
|  { | ||||
|  	struct dsa_switch_tree *dst = ds->dst; | ||||
| @@ -282,6 +291,18 @@ static inline u8 dsa_upstream_port(struc
 | ||||
|  		return ds->rtable[dst->cpu_dp->ds->index]; | ||||
|  } | ||||
|   | ||||
| +static inline u8 dsa_port_upstream_port(struct dsa_switch *ds, int port)
 | ||||
| +{
 | ||||
| +	/*
 | ||||
| +	 * If this port has a specific upstream cpu port, use it,
 | ||||
| +	 * otherwise use the switch default.
 | ||||
| +	 */
 | ||||
| +	if (ds->ports[port].upstream)
 | ||||
| +		return ds->ports[port].upstream;
 | ||||
| +	else
 | ||||
| +		return dsa_upstream_port(ds);
 | ||||
| +}
 | ||||
| +
 | ||||
|  typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, | ||||
|  			      bool is_static, void *data); | ||||
|  struct dsa_switch_ops { | ||||
| --- a/net/dsa/dsa2.c
 | ||||
| +++ b/net/dsa/dsa2.c
 | ||||
| @@ -253,6 +253,8 @@ static int dsa_cpu_port_apply(struct dsa
 | ||||
|  	memset(&port->devlink_port, 0, sizeof(port->devlink_port)); | ||||
|  	err = devlink_port_register(ds->devlink, &port->devlink_port, | ||||
|  				    port->index); | ||||
| +	if (port->netdev)
 | ||||
| +		port->netdev->dsa_ptr = ds->dst;
 | ||||
|  	return err; | ||||
|  } | ||||
|   | ||||
| @@ -262,6 +264,12 @@ static void dsa_cpu_port_unapply(struct
 | ||||
|  	dsa_cpu_dsa_destroy(port); | ||||
|  	port->ds->cpu_port_mask &= ~BIT(port->index); | ||||
|   | ||||
| +	if (port->netdev)
 | ||||
| +		port->netdev->dsa_ptr = NULL;
 | ||||
| +	if (port->ethernet) {
 | ||||
| +		dev_put(port->ethernet);
 | ||||
| +		port->ethernet = NULL;
 | ||||
| +	}
 | ||||
|  } | ||||
|   | ||||
|  static int dsa_user_port_apply(struct dsa_port *port) | ||||
| @@ -505,10 +513,9 @@ static int dsa_cpu_parse(struct dsa_port
 | ||||
|  		dev_put(ethernet_dev); | ||||
|  	} | ||||
|   | ||||
| -	if (!dst->cpu_dp) {
 | ||||
| +	if (!dst->cpu_dp)
 | ||||
|  		dst->cpu_dp = port; | ||||
| -		dst->cpu_dp->netdev = ethernet_dev;
 | ||||
| -	}
 | ||||
| +	port->netdev = ethernet_dev;
 | ||||
|   | ||||
|  	/* Initialize cpu_port_mask now for drv->setup() | ||||
|  	 * to have access to a correct value, just like what | ||||
| @@ -526,6 +533,29 @@ static int dsa_cpu_parse(struct dsa_port
 | ||||
|   | ||||
|  	dst->rcv = dst->tag_ops->rcv; | ||||
|   | ||||
| +	dev_hold(ethernet_dev);
 | ||||
| +	ds->ports[index].ethernet = ethernet_dev;
 | ||||
| +	ds->cpu_port_mask |= BIT(index);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int dsa_user_parse(struct dsa_port *port, u32 index,
 | ||||
| +			  struct dsa_switch *ds)
 | ||||
| +{
 | ||||
| +	struct device_node *cpu_port;
 | ||||
| +	const unsigned int *cpu_port_reg;
 | ||||
| +	int cpu_port_index;
 | ||||
| +
 | ||||
| +	cpu_port = of_parse_phandle(port->dn, "cpu", 0);
 | ||||
| +	if (cpu_port) {
 | ||||
| +		cpu_port_reg = of_get_property(cpu_port, "reg", NULL);
 | ||||
| +		if (!cpu_port_reg)
 | ||||
| +			return -EINVAL;
 | ||||
| +		cpu_port_index = be32_to_cpup(cpu_port_reg);
 | ||||
| +		ds->ports[index].upstream = cpu_port_index;
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| @@ -533,7 +563,7 @@ static int dsa_ds_parse(struct dsa_switc
 | ||||
|  { | ||||
|  	struct dsa_port *port; | ||||
|  	u32 index; | ||||
| -	int err;
 | ||||
| +	int err = 0;
 | ||||
|   | ||||
|  	for (index = 0; index < ds->num_ports; index++) { | ||||
|  		port = &ds->ports[index]; | ||||
| @@ -546,6 +576,9 @@ static int dsa_ds_parse(struct dsa_switc
 | ||||
|  			if (err) | ||||
|  				return err; | ||||
|  		} else { | ||||
| +			err = dsa_user_parse(port, index, ds);
 | ||||
| +			if (err)
 | ||||
| +				return err;
 | ||||
|  			/* Initialize enabled_port_mask now for drv->setup() | ||||
|  			 * to have access to a correct value, just like what | ||||
|  			 * net/dsa/dsa.c::dsa_switch_setup_one does. | ||||
| --- a/net/dsa/dsa_priv.h
 | ||||
| +++ b/net/dsa/dsa_priv.h
 | ||||
| @@ -91,6 +91,8 @@ struct dsa_slave_priv {
 | ||||
|   | ||||
|  	/* TC context */ | ||||
|  	struct list_head	mall_tc_list; | ||||
| +
 | ||||
| +	struct net_device       *master;
 | ||||
|  }; | ||||
|   | ||||
|  /* dsa.c */ | ||||
| @@ -177,6 +179,9 @@ extern const struct dsa_device_ops trail
 | ||||
|   | ||||
|  static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p) | ||||
|  { | ||||
| +	if (p->master)
 | ||||
| +		return p->master;
 | ||||
| +
 | ||||
|  	return p->dp->cpu_dp->netdev; | ||||
|  } | ||||
|   | ||||
| --- a/net/dsa/slave.c
 | ||||
| +++ b/net/dsa/slave.c
 | ||||
| @@ -1257,7 +1257,7 @@ int dsa_slave_create(struct dsa_port *po
 | ||||
|  	int ret; | ||||
|   | ||||
|  	cpu_dp = ds->dst->cpu_dp; | ||||
| -	master = cpu_dp->netdev;
 | ||||
| +	master = ds->ports[port->upstream].ethernet;
 | ||||
|   | ||||
|  	if (!ds->num_tx_queues) | ||||
|  		ds->num_tx_queues = 1; | ||||
| @@ -1295,6 +1295,7 @@ int dsa_slave_create(struct dsa_port *po
 | ||||
|  	p->dp = port; | ||||
|  	INIT_LIST_HEAD(&p->mall_tc_list); | ||||
|  	p->xmit = dst->tag_ops->xmit; | ||||
| +	p->master = master;
 | ||||
|   | ||||
|  	p->old_pause = -1; | ||||
|  	p->old_link = -1; | ||||
|  | @ -0,0 +1,47 @@ | |||
| From 35b83b85e752a6660b92f08c0fb912308f25cf6d Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 15:56:40 +0200 | ||||
| Subject: [PATCH 35/57] net: mediatek: disable RX VLan offloading | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 ++++++--- | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 -- | ||||
|  2 files changed, 6 insertions(+), 5 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -709,8 +709,8 @@ static int mtk_tx_map(struct sk_buff *sk
 | ||||
|  		txd4 |= TX_DMA_CHKSUM; | ||||
|   | ||||
|  	/* VLAN header offload */ | ||||
| -	if (skb_vlan_tag_present(skb))
 | ||||
| -		txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb);
 | ||||
| +//	if (skb_vlan_tag_present(skb))
 | ||||
| +//		txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb);
 | ||||
|   | ||||
|  	mapped_addr = dma_map_single(eth->dev, skb->data, | ||||
|  				     skb_headlen(skb), DMA_TO_DEVICE); | ||||
| @@ -1980,7 +1980,10 @@ static int mtk_hw_init(struct mtk_eth *e
 | ||||
|  	mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); | ||||
|   | ||||
|  	/* Enable RX VLan Offloading */ | ||||
| -	mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
 | ||||
| +	if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX)
 | ||||
| +		mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
 | ||||
| +	else
 | ||||
| +		mtk_w32(eth, 0, MTK_CDMP_EG_CTRL);
 | ||||
|   | ||||
|  	/* enable interrupt delay for RX */ | ||||
|  	mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| @@ -34,8 +34,6 @@
 | ||||
|  				 NETIF_MSG_TX_ERR) | ||||
|  #define MTK_HW_FEATURES		(NETIF_F_IP_CSUM | \ | ||||
|  				 NETIF_F_RXCSUM | \ | ||||
| -				 NETIF_F_HW_VLAN_CTAG_TX | \
 | ||||
| -				 NETIF_F_HW_VLAN_CTAG_RX | \
 | ||||
|  				 NETIF_F_SG | NETIF_F_TSO | \ | ||||
|  				 NETIF_F_TSO6 | \ | ||||
|  				 NETIF_F_IPV6_CSUM) | ||||
|  | @ -0,0 +1,50 @@ | |||
| From a306af3b97c56b9e224a2f9ee04838a2d32ff60b Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Wed, 9 Aug 2017 14:44:07 +0200 | ||||
| Subject: [PATCH 42/57] net-next: mediatek: honour special tag bit inside RX | ||||
|  DMA descriptor | ||||
| 
 | ||||
| For HW NAT/QoS to work the DSA driver needs to turn the special tag bit | ||||
| inside the ingress control register on. This has the side effect that | ||||
| the code working out which ingress gmac we have breaks. Fix this by | ||||
| honouring the special tag bit inside the RX free descriptor. | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 14 ++++++++++---- | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.h |  1 + | ||||
|  2 files changed, 11 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -999,10 +999,16 @@ static int mtk_poll_rx(struct napi_struc
 | ||||
|  		if (!(trxd.rxd2 & RX_DMA_DONE)) | ||||
|  			break; | ||||
|   | ||||
| -		/* find out which mac the packet come from. values start at 1 */
 | ||||
| -		mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
 | ||||
| -		      RX_DMA_FPORT_MASK;
 | ||||
| -		mac--;
 | ||||
| +		/* find out which mac the packet comes from. If the special tag is
 | ||||
| +		 * we can assume that the traffic is coming from the builtin mt7530
 | ||||
| +		 * and the DSA driver has loaded. FPORT will be the physical switch
 | ||||
| +		 * port in this case rather than the FE forward port id. */
 | ||||
| +		if (!(trxd.rxd4 & RX_DMA_SP_TAG)) {
 | ||||
| +			/* values start at 1 */
 | ||||
| +			mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
 | ||||
| +			      RX_DMA_FPORT_MASK;
 | ||||
| +			mac--;
 | ||||
| +		}
 | ||||
|   | ||||
|  		if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || | ||||
|  			     !eth->netdev[mac])) | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| @@ -287,6 +287,7 @@
 | ||||
|   | ||||
|  /* QDMA descriptor rxd4 */ | ||||
|  #define RX_DMA_L4_VALID		BIT(24) | ||||
| +#define RX_DMA_SP_TAG		BIT(22)
 | ||||
|  #define RX_DMA_FPORT_SHIFT	19 | ||||
|  #define RX_DMA_FPORT_MASK	0x7 | ||||
|   | ||||
|  | @ -0,0 +1,41 @@ | |||
| From 53e3d9af39805a7e1ba81a047a9ab433be0e82f5 Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Wed, 9 Aug 2017 14:56:53 +0200 | ||||
| Subject: [PATCH 43/57] net-next: mediatek: enable special tag indication for | ||||
|  PDMA | ||||
| 
 | ||||
| The Ingress special tag indication was only enabled for QDMA and not PDMA. | ||||
| Properly initialize the STAG bit. This broke HW NAT and Qos from working | ||||
| for traffic coming in via a DSA device. The PPE failed to properly parse | ||||
| the traffic as it was not expecting the special tag. | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++ | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++++ | ||||
|  2 files changed, 6 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -1984,6 +1984,8 @@ static int mtk_hw_init(struct mtk_eth *e
 | ||||
|  	 */ | ||||
|  	val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); | ||||
|  	mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); | ||||
| +	val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
 | ||||
| +	mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);
 | ||||
|   | ||||
|  	/* Enable RX VLan Offloading */ | ||||
|  	if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX) | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | ||||
| @@ -72,6 +72,10 @@
 | ||||
|  #define MTK_CDMQ_IG_CTRL	0x1400 | ||||
|  #define MTK_CDMQ_STAG_EN	BIT(0) | ||||
|   | ||||
| +/* CDMP Ingress Control Register */
 | ||||
| +#define MTK_CDMP_IG_CTRL	0x400
 | ||||
| +#define MTK_CDMP_STAG_EN	BIT(0)
 | ||||
| +
 | ||||
|  /* CDMP Exgress Control Register */ | ||||
|  #define MTK_CDMP_EG_CTRL	0x404 | ||||
|   | ||||
|  | @ -0,0 +1,43 @@ | |||
| From 6a5932028a4f3217ed7c9d602f269611d95dd8ca Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Wed, 9 Aug 2017 15:13:19 +0200 | ||||
| Subject: [PATCH 44/57] net-next: dsa: mediatek: tell GDMA when we are turning | ||||
|  on the special tag | ||||
| 
 | ||||
| Enabling this bit will make the RX DMA descriptor enable the SP bit for all | ||||
| ingress traffic inside the return descriptor. The PPE needs this to know | ||||
| that a SP is present. | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/dsa/mt7530.c | 5 +++++ | ||||
|  drivers/net/dsa/mt7530.h | 4 ++++ | ||||
|  2 files changed, 9 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/net/dsa/mt7530.c
 | ||||
| +++ b/drivers/net/dsa/mt7530.c
 | ||||
| @@ -677,6 +677,11 @@ mt7530_cpu_port_enable(struct mt7530_pri
 | ||||
|  	mt7530_write(priv, MT7530_PVC_P(port), | ||||
|  		     PORT_SPEC_TAG); | ||||
|   | ||||
| +	/* Enable Mediatek header mode on the GMAC that the cpu port
 | ||||
| +	 * connects to */
 | ||||
| +	regmap_write_bits(priv->ethernet, MTK_GDMA_FWD_CFG(port),
 | ||||
| +			  GDMA_SPEC_TAG, GDMA_SPEC_TAG);
 | ||||
| +
 | ||||
|  	/* Setup the MAC by default for the cpu port */ | ||||
|  	mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPUP_LINK); | ||||
|   | ||||
| --- a/drivers/net/dsa/mt7530.h
 | ||||
| +++ b/drivers/net/dsa/mt7530.h
 | ||||
| @@ -22,6 +22,10 @@
 | ||||
|   | ||||
|  #define TRGMII_BASE(x)			(0x10000 + (x)) | ||||
|   | ||||
| +/* Registers for GDMA configuration access */
 | ||||
| +#define MTK_GDMA_FWD_CFG(x)		(0x500 + (x * 0x1000))
 | ||||
| +#define GDMA_SPEC_TAG			BIT(24)
 | ||||
| +
 | ||||
|  /* Registers to ethsys access */ | ||||
|  #define ETHSYS_CLKCFG0			0x2c | ||||
|  #define  ETHSYS_TRGMII_CLK_SEL362_5	BIT(11) | ||||
|  | @ -0,0 +1,79 @@ | |||
| From 1e33784f665cb95c2af5481d3e776d2d3099921b Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 15:57:17 +0200 | ||||
| Subject: [PATCH 45/57] net: dsa: mediatek: turn into platform driver | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/dsa/mt7530.c | 23 +++++++++++++++-------- | ||||
|  1 file changed, 15 insertions(+), 8 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/net/dsa/mt7530.c
 | ||||
| +++ b/drivers/net/dsa/mt7530.c
 | ||||
| @@ -1049,10 +1049,10 @@ static const struct dsa_switch_ops mt753
 | ||||
|  }; | ||||
|   | ||||
|  static int | ||||
| -mt7530_probe(struct mdio_device *mdiodev)
 | ||||
| +mt7530_probe(struct platform_device *mdiodev)
 | ||||
|  { | ||||
|  	struct mt7530_priv *priv; | ||||
| -	struct device_node *dn;
 | ||||
| +	struct device_node *dn, *mdio;
 | ||||
|   | ||||
|  	dn = mdiodev->dev.of_node; | ||||
|   | ||||
| @@ -1100,7 +1100,12 @@ mt7530_probe(struct mdio_device *mdiodev
 | ||||
|  		} | ||||
|  	} | ||||
|   | ||||
| -	priv->bus = mdiodev->bus;
 | ||||
| +	mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
 | ||||
| +	if (!mdio)
 | ||||
| +		return -EINVAL;
 | ||||
| +	priv->bus = of_mdio_find_bus(mdio);
 | ||||
| +	if (!priv->bus)
 | ||||
| +		return -EPROBE_DEFER;
 | ||||
|  	priv->dev = &mdiodev->dev; | ||||
|  	priv->ds->priv = priv; | ||||
|  	priv->ds->ops = &mt7530_switch_ops; | ||||
| @@ -1110,8 +1115,8 @@ mt7530_probe(struct mdio_device *mdiodev
 | ||||
|  	return dsa_register_switch(priv->ds); | ||||
|  } | ||||
|   | ||||
| -static void
 | ||||
| -mt7530_remove(struct mdio_device *mdiodev)
 | ||||
| +static int
 | ||||
| +mt7530_remove(struct platform_device *mdiodev)
 | ||||
|  { | ||||
|  	struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev); | ||||
|  	int ret = 0; | ||||
| @@ -1128,6 +1133,8 @@ mt7530_remove(struct mdio_device *mdiode
 | ||||
|   | ||||
|  	dsa_unregister_switch(priv->ds); | ||||
|  	mutex_destroy(&priv->reg_mutex); | ||||
| +
 | ||||
| +	return 0;
 | ||||
|  } | ||||
|   | ||||
|  static const struct of_device_id mt7530_of_match[] = { | ||||
| @@ -1136,16 +1143,16 @@ static const struct of_device_id mt7530_
 | ||||
|  }; | ||||
|  MODULE_DEVICE_TABLE(of, mt7530_of_match); | ||||
|   | ||||
| -static struct mdio_driver mt7530_mdio_driver = {
 | ||||
| +static struct platform_driver mtk_mt7530_driver = {
 | ||||
|  	.probe  = mt7530_probe, | ||||
|  	.remove = mt7530_remove, | ||||
| -	.mdiodrv.driver = {
 | ||||
| +	.driver = {
 | ||||
|  		.name = "mt7530", | ||||
|  		.of_match_table = mt7530_of_match, | ||||
|  	}, | ||||
|  }; | ||||
| +module_platform_driver(mtk_mt7530_driver);
 | ||||
|   | ||||
| -mdio_module_driver(mt7530_mdio_driver);
 | ||||
|   | ||||
|  MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>"); | ||||
|  MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch"); | ||||
|  | @ -0,0 +1,21 @@ | |||
| From 6e081074df96bf3762c2e6438c383f11a56b0a7e Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 15:58:04 +0200 | ||||
| Subject: [PATCH 46/57] net: mediatek: add irq delay | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 ++++++- | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++++++- | ||||
|  2 files changed, 13 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -1995,6 +1995,7 @@ static int mtk_hw_init(struct mtk_eth *e
 | ||||
|   | ||||
|  	/* enable interrupt delay for RX */ | ||||
|  	mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); | ||||
| +	//mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_QDMA_DELAY_INT);
 | ||||
|   | ||||
|  	/* disable delay and normal interrupt */ | ||||
|  	mtk_w32(eth, 0, MTK_QDMA_DELAY_INT); | ||||
|  | @ -0,0 +1,90 @@ | |||
| From 3e969c9695b45e1a052d43b367096ec99f2f0aac Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 15:58:29 +0200 | ||||
| Subject: [PATCH 48/57] net: core: add RPS balancer | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  net/core/dev.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- | ||||
|  1 file changed, 56 insertions(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/net/core/dev.c
 | ||||
| +++ b/net/core/dev.c
 | ||||
| @@ -3636,6 +3636,58 @@ set_rps_cpu(struct net_device *dev, stru
 | ||||
|  	return rflow; | ||||
|  } | ||||
|   | ||||
| +#define RPS_TBL_SIZE_SHIFT	10
 | ||||
| +#define RPS_TBL_SIZE		(1 << RPS_TBL_SIZE_SHIFT)
 | ||||
| +struct rps_table {
 | ||||
| +	int			core;
 | ||||
| +	struct timer_list	expire;
 | ||||
| +};
 | ||||
| +static struct rps_table rps_table[RPS_TBL_SIZE];
 | ||||
| +static int rps_table_last_core;
 | ||||
| +
 | ||||
| +static void rps_table_expire(unsigned long data)
 | ||||
| +{
 | ||||
| +	struct rps_table *entry = (struct rps_table *) data;
 | ||||
| +
 | ||||
| +	entry->core = -1;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int rps_table_core(struct rps_map *map)
 | ||||
| +{
 | ||||
| +	int i;
 | ||||
| +
 | ||||
| +	for (i = 0; i < map->len; i++) {
 | ||||
| +		int cpu = map->cpus[(rps_table_last_core + i + 1) % map->len];
 | ||||
| +		if (cpu_online(cpu)) {
 | ||||
| +			rps_table_last_core = cpu;
 | ||||
| +			return cpu;
 | ||||
| +		}
 | ||||
| +	}
 | ||||
| +	return map->cpus[0];
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int rps_table_lookup(struct rps_map *map, u32 hash)
 | ||||
| +{
 | ||||
| +	int bucket = hash & 0x3ff;
 | ||||
| +
 | ||||
| +	if (rps_table[bucket].core < 0)
 | ||||
| +		rps_table[bucket].core = rps_table_core(map);
 | ||||
| +	mod_timer(&rps_table[bucket].expire, jiffies + HZ);
 | ||||
| +
 | ||||
| +	return rps_table[bucket].core;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void rps_table_init(void)
 | ||||
| +{
 | ||||
| +	int i;
 | ||||
| +
 | ||||
| +	for (i = 0; i < RPS_TBL_SIZE; i++) {
 | ||||
| +		rps_table[i].core = -1;
 | ||||
| +		setup_timer(&rps_table[i].expire, rps_table_expire,
 | ||||
| +			    (unsigned long) &rps_table[i]);
 | ||||
| +	}
 | ||||
| +}
 | ||||
| +
 | ||||
|  /* | ||||
|   * get_rps_cpu is called from netif_receive_skb and returns the target | ||||
|   * CPU from the RPS map of the receiving queue for a given skb. | ||||
| @@ -3725,7 +3777,7 @@ static int get_rps_cpu(struct net_device
 | ||||
|  try_rps: | ||||
|   | ||||
|  	if (map) { | ||||
| -		tcpu = map->cpus[reciprocal_scale(hash, map->len)];
 | ||||
| +		tcpu = rps_table_lookup(map, hash);
 | ||||
|  		if (cpu_online(tcpu)) { | ||||
|  			cpu = tcpu; | ||||
|  			goto done; | ||||
| @@ -8810,6 +8862,9 @@ static int __init net_dev_init(void)
 | ||||
|  		sd->backlog.weight = weight_p; | ||||
|  	} | ||||
|   | ||||
| +	if (IS_ENABLED(CONFIG_RPS))
 | ||||
| +		rps_table_init();
 | ||||
| +
 | ||||
|  	dev_boot_phase = 0; | ||||
|   | ||||
|  	/* The loopback device is special if any other network devices | ||||
|  | @ -0,0 +1,21 @@ | |||
| From 5cbf53c7e5eac5bacc409461888789accdaf8eec Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 16:00:06 +0200 | ||||
| Subject: [PATCH 51/57] net: mediatek: increase tx_timeout | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -2454,7 +2454,7 @@ static int mtk_add_mac(struct mtk_eth *e
 | ||||
|  	mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; | ||||
|   | ||||
|  	SET_NETDEV_DEV(eth->netdev[id], eth->dev); | ||||
| -	eth->netdev[id]->watchdog_timeo = 5 * HZ;
 | ||||
| +	eth->netdev[id]->watchdog_timeo = 30 * HZ;
 | ||||
|  	eth->netdev[id]->netdev_ops = &mtk_netdev_ops; | ||||
|  	eth->netdev[id]->base_addr = (unsigned long)eth->base; | ||||
|   | ||||
|  | @ -0,0 +1,21 @@ | |||
| From 18b2169d84b47a3414164e5e40f23fb7e875707c Mon Sep 17 00:00:00 2001 | ||||
| From: John Crispin <john@phrozen.org> | ||||
| Date: Thu, 10 Aug 2017 16:00:28 +0200 | ||||
| Subject: [PATCH 52/57] net: phy: add FC | ||||
| 
 | ||||
| Signed-off-by: John Crispin <john@phrozen.org> | ||||
| ---
 | ||||
|  drivers/net/phy/phy_device.c | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/net/phy/phy_device.c
 | ||||
| +++ b/drivers/net/phy/phy_device.c
 | ||||
| @@ -1929,7 +1929,7 @@ static struct phy_driver genphy_driver =
 | ||||
|  	.config_init	= genphy_config_init, | ||||
|  	.features	= PHY_GBIT_FEATURES | SUPPORTED_MII | | ||||
|  			  SUPPORTED_AUI | SUPPORTED_FIBRE | | ||||
| -			  SUPPORTED_BNC,
 | ||||
| +			  SUPPORTED_BNC | SUPPORTED_Pause | SUPPORTED_Asym_Pause,
 | ||||
|  	.config_aneg	= genphy_config_aneg, | ||||
|  	.aneg_done	= genphy_aneg_done, | ||||
|  	.read_status	= genphy_read_status, | ||||
|  | @ -0,0 +1,14 @@ | |||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -76,7 +76,10 @@ static int mtk_mdio_busy_wait(struct mtk
 | ||||
|  			return 0; | ||||
|  		if (time_after(jiffies, t_start + PHY_IAC_TIMEOUT)) | ||||
|  			break; | ||||
| -		usleep_range(10, 20);
 | ||||
| +		if (in_atomic())
 | ||||
| +			udelay(10);
 | ||||
| +		else
 | ||||
| +			usleep_range(10, 20);
 | ||||
|  	} | ||||
|   | ||||
|  	dev_err(eth->dev, "mdio: MDIO timeout\n"); | ||||
|  | @ -0,0 +1,46 @@ | |||
| --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | ||||
| @@ -409,6 +409,7 @@ static int mtk_mdio_init(struct mtk_eth
 | ||||
|   | ||||
|  	snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name); | ||||
|  	ret = of_mdiobus_register(eth->mii_bus, mii_np); | ||||
| +printk("%s:%s[%d]%d %p\n", __FILE__, __func__, __LINE__, ret, eth->mii_bus);
 | ||||
|   | ||||
|  err_put_node: | ||||
|  	of_node_put(mii_np); | ||||
| @@ -1472,7 +1473,10 @@ static void mtk_hwlro_rx_uninit(struct m
 | ||||
|  	for (i = 0; i < 10; i++) { | ||||
|  		val = mtk_r32(eth, MTK_PDMA_LRO_CTRL_DW0); | ||||
|  		if (val & MTK_LRO_RING_RELINQUISH_DONE) { | ||||
| -			msleep(20);
 | ||||
| +			if (in_atomic())
 | ||||
| +				mdelay(20);
 | ||||
| +			else
 | ||||
| +				msleep(20);
 | ||||
|  			continue; | ||||
|  		} | ||||
|  		break; | ||||
| @@ -1868,7 +1872,10 @@ static void mtk_stop_dma(struct mtk_eth
 | ||||
|  	for (i = 0; i < 10; i++) { | ||||
|  		val = mtk_r32(eth, glo_cfg); | ||||
|  		if (val & (MTK_TX_DMA_BUSY | MTK_RX_DMA_BUSY)) { | ||||
| -			msleep(20);
 | ||||
| +			if (in_atomic())
 | ||||
| +				mdelay(20);
 | ||||
| +			else
 | ||||
| +				msleep(20);
 | ||||
|  			continue; | ||||
|  		} | ||||
|  		break; | ||||
| @@ -1906,7 +1913,10 @@ static void ethsys_reset(struct mtk_eth
 | ||||
|  			   reset_bits, | ||||
|  			   reset_bits); | ||||
|   | ||||
| -	usleep_range(1000, 1100);
 | ||||
| +	if (in_atomic())
 | ||||
| +		udelay(1000);
 | ||||
| +	else
 | ||||
| +		usleep_range(1000, 1100);
 | ||||
|  	regmap_update_bits(eth->ethsys, ETHSYS_RSTCTRL, | ||||
|  			   reset_bits, | ||||
|  			   ~reset_bits); | ||||
							
								
								
									
										589
									
								
								root/target/linux/mediatek/patches-4.14/0064-dts.patch
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										589
									
								
								root/target/linux/mediatek/patches-4.14/0064-dts.patch
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,589 @@ | |||
| --- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
 | ||||
| +++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
 | ||||
| @@ -21,6 +21,10 @@
 | ||||
|  		stdout-path = "serial2:115200n8"; | ||||
|  	}; | ||||
|   | ||||
| +	memory {
 | ||||
| +		reg = <0 0x80000000 0 0x20000000>;
 | ||||
| +	};
 | ||||
| +
 | ||||
|  	cpus { | ||||
|  		cpu@0 { | ||||
|  			proc-supply = <&mt6323_vproc_reg>; | ||||
| @@ -103,6 +107,10 @@
 | ||||
|  		device_type = "memory"; | ||||
|  		reg = <0 0x80000000 0 0x40000000>; | ||||
|  	}; | ||||
| +
 | ||||
| +	mt7530: switch@0 {
 | ||||
| +		compatible = "mediatek,mt7530";
 | ||||
| +	};
 | ||||
|  }; | ||||
|   | ||||
|  &cir { | ||||
| @@ -130,11 +138,24 @@
 | ||||
|  		}; | ||||
|  	}; | ||||
|   | ||||
| +	gmac1: mac@1 {
 | ||||
| +		compatible = "mediatek,eth-mac";
 | ||||
| +		reg = <1>;
 | ||||
| +		phy-mode = "rgmii";
 | ||||
| +
 | ||||
| +		fixed-link {
 | ||||
| +			speed = <1000>;
 | ||||
| +			full-duplex;
 | ||||
| +			pause;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
|  	mdio: mdio-bus { | ||||
|  		#address-cells = <1>; | ||||
|  		#size-cells = <0>; | ||||
| -
 | ||||
| -		switch@0 {
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +		&mt7530 {
 | ||||
|  			compatible = "mediatek,mt7530"; | ||||
|  			#address-cells = <1>; | ||||
|  			#size-cells = <0>; | ||||
| @@ -144,6 +165,8 @@
 | ||||
|  			core-supply = <&mt6323_vpa_reg>; | ||||
|  			io-supply = <&mt6323_vemc3v3_reg>; | ||||
|   | ||||
| +			dsa,mii-bus = <&mdio>;
 | ||||
| +
 | ||||
|  			ports { | ||||
|  				#address-cells = <1>; | ||||
|  				#size-cells = <0>; | ||||
| @@ -152,29 +175,46 @@
 | ||||
|  				port@0 { | ||||
|  					reg = <0>; | ||||
|  					label = "wan"; | ||||
| +					cpu = <&cpu_port1>;
 | ||||
|  				}; | ||||
|   | ||||
|  				port@1 { | ||||
|  					reg = <1>; | ||||
|  					label = "lan0"; | ||||
| +					cpu = <&cpu_port0>;
 | ||||
|  				}; | ||||
|   | ||||
|  				port@2 { | ||||
|  					reg = <2>; | ||||
|  					label = "lan1"; | ||||
| +					cpu = <&cpu_port0>;
 | ||||
|  				}; | ||||
|   | ||||
|  				port@3 { | ||||
|  					reg = <3>; | ||||
|  					label = "lan2"; | ||||
| +					cpu = <&cpu_port0>;
 | ||||
|  				}; | ||||
|   | ||||
|  				port@4 { | ||||
|  					reg = <4>; | ||||
|  					label = "lan3"; | ||||
| +					cpu = <&cpu_port0>;
 | ||||
|  				}; | ||||
|   | ||||
| -				port@6 {
 | ||||
| +				cpu_port1: port@5 {
 | ||||
| +					reg = <5>;
 | ||||
| +					label = "cpu";
 | ||||
| +					ethernet = <&gmac1>;
 | ||||
| +					phy-mode = "rgmii";
 | ||||
| +
 | ||||
| +					fixed-link {
 | ||||
| +						speed = <1000>;
 | ||||
| +						full-duplex;
 | ||||
| +					};
 | ||||
| +				};
 | ||||
| +
 | ||||
| +				cpu_port0: port@6 {
 | ||||
|  					reg = <6>; | ||||
|  					label = "cpu"; | ||||
|  					ethernet = <&gmac0>; | ||||
| @@ -187,8 +227,6 @@
 | ||||
|  				}; | ||||
|  			}; | ||||
|  		}; | ||||
| -	};
 | ||||
| -};
 | ||||
|   | ||||
|  &i2c0 { | ||||
|  	pinctrl-names = "default"; | ||||
| --- a/arch/arm/boot/dts/Makefile
 | ||||
| +++ b/arch/arm/boot/dts/Makefile
 | ||||
| @@ -1061,6 +1061,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
 | ||||
|  	mt6580-evbp1.dtb \ | ||||
|  	mt6589-aquaris5.dtb \ | ||||
|  	mt6592-evb.dtb \ | ||||
| +	mt7623a-rfb-emmc.dtb \
 | ||||
|  	mt7623n-rfb-nand.dtb \ | ||||
|  	mt7623n-bananapi-bpi-r2.dtb \ | ||||
|  	mt8127-moose.dtb \ | ||||
| --- /dev/null
 | ||||
| +++ b/arch/arm/boot/dts/mt7623a-rfb-emmc.dts
 | ||||
| @@ -0,0 +1,449 @@
 | ||||
| +/*
 | ||||
| + * Copyright 2017 Sean Wang <sean.wang@mediatek.com>
 | ||||
| + *
 | ||||
| + * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 | ||||
| + */
 | ||||
| +
 | ||||
| +/dts-v1/;
 | ||||
| +#include <dt-bindings/input/input.h>
 | ||||
| +#include "mt7623.dtsi"
 | ||||
| +#include "mt6323.dtsi"
 | ||||
| +
 | ||||
| +/ {
 | ||||
| +	model = "MediaTek MT7623N NAND reference board";
 | ||||
| +	compatible = "mediatek,mt7623a-rfb-emmc", "mediatek,mt7623";
 | ||||
| +
 | ||||
| +	aliases {
 | ||||
| +		serial2 = &uart2;
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	chosen {
 | ||||
| +		bootargs = "earlyprintk block2mtd.block2mtd=/dev/mmcblk0,65536,eMMC,5 mtdparts=eMMC:256k(mbr)ro,512k(uboot)ro,256k(config)ro,256k(factory)ro,32M(kernel),32M(recovery),1024M(rootfs),2048M(usrdata),-(bmtpool) rootfstype=squashfs,jffs2";
 | ||||
| +
 | ||||
| +		stdout-path = "serial2:115200n8";
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	memory {
 | ||||
| +		reg = <0 0x80000000 0 0x20000000>;
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	cpus {
 | ||||
| +		cpu@0 {
 | ||||
| +			proc-supply = <&mt6323_vproc_reg>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		cpu@1 {
 | ||||
| +			proc-supply = <&mt6323_vproc_reg>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		cpu@2 {
 | ||||
| +			proc-supply = <&mt6323_vproc_reg>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		cpu@3 {
 | ||||
| +			proc-supply = <&mt6323_vproc_reg>;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	memory@80000000 {
 | ||||
| +		reg = <0 0x80000000 0 0x40000000>;
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mt7530: switch@0 {
 | ||||
| +		compatible = "mediatek,mt7530";
 | ||||
| +		#address-cells = <1>;
 | ||||
| +		#size-cells = <0>;
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +
 | ||||
| +&crypto {
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +ð {
 | ||||
| +	status = "okay";
 | ||||
| +
 | ||||
| +	gmac0: mac@0 {
 | ||||
| +		compatible = "mediatek,eth-mac";
 | ||||
| +		reg = <0>;
 | ||||
| +		phy-mode = "trgmii";
 | ||||
| +
 | ||||
| +		fixed-link {
 | ||||
| +			speed = <1000>;
 | ||||
| +			full-duplex;
 | ||||
| +			pause;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	gmac1: mac@1 {
 | ||||
| +		compatible = "mediatek,eth-mac";
 | ||||
| +		reg = <1>;
 | ||||
| +		phy-mode = "rgmiii-rxid";
 | ||||
| +		phy-handle = <&phy5>;
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mdio: mdio-bus {
 | ||||
| +		#address-cells = <1>;
 | ||||
| +		#size-cells = <0>;
 | ||||
| +		phy5: ethernet-phy@5 {
 | ||||
| +			reg = <5>;
 | ||||
| +			phy-mode = "rgmii-rxid";
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +
 | ||||
| +&mt7530 {
 | ||||
| +	compatible = "mediatek,mt7530";
 | ||||
| +	#address-cells = <1>;
 | ||||
| +	#size-cells = <0>;
 | ||||
| +	reg = <0>;
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	mediatek,mcm;
 | ||||
| +	resets = <ðsys 2>;
 | ||||
| +	reset-names = "mcm";
 | ||||
| +	core-supply = <&mt6323_vpa_reg>;
 | ||||
| +	io-supply = <&mt6323_vemc3v3_reg>;
 | ||||
| +
 | ||||
| +	dsa,mii-bus = <&mdio>;
 | ||||
| +
 | ||||
| +	ports {
 | ||||
| +		#address-cells = <1>;
 | ||||
| +		#size-cells = <0>;
 | ||||
| +		reg = <0>;
 | ||||
| +
 | ||||
| +		port@0 {
 | ||||
| +			reg = <0>;
 | ||||
| +			label = "lan0";
 | ||||
| +			cpu = <&cpu_port0>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		port@1 {
 | ||||
| +			reg = <1>;
 | ||||
| +			label = "lan1";
 | ||||
| +			cpu = <&cpu_port0>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		port@2 {
 | ||||
| +			reg = <2>;
 | ||||
| +			label = "lan2";
 | ||||
| +			cpu = <&cpu_port0>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		port@3 {
 | ||||
| +			reg = <3>;
 | ||||
| +			label = "lan3";
 | ||||
| +			cpu = <&cpu_port0>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		cpu_port0: port@6 {
 | ||||
| +			reg = <6>;
 | ||||
| +			label = "cpu";
 | ||||
| +			ethernet = <&gmac0>;
 | ||||
| +			phy-mode = "trgmii";
 | ||||
| +
 | ||||
| +			fixed-link {
 | ||||
| +				speed = <1000>;
 | ||||
| +				full-duplex;
 | ||||
| +			};
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +
 | ||||
| +&i2c0 {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&i2c0_pins_a>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&i2c1 {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&i2c1_pins_a>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&mmc0 {
 | ||||
| +	pinctrl-names = "default", "state_uhs";
 | ||||
| +	pinctrl-0 = <&mmc0_pins_default>;
 | ||||
| +	pinctrl-1 = <&mmc0_pins_uhs>;
 | ||||
| +	status = "okay";
 | ||||
| +	bus-width = <8>;
 | ||||
| +	max-frequency = <50000000>;
 | ||||
| +	cap-mmc-highspeed;
 | ||||
| +	vmmc-supply = <&mt6323_vemc3v3_reg>;
 | ||||
| +	vqmmc-supply = <&mt6323_vio18_reg>;
 | ||||
| +	non-removable;
 | ||||
| +};
 | ||||
| +
 | ||||
| +&mmc1 {
 | ||||
| +	pinctrl-names = "default", "state_uhs";
 | ||||
| +	pinctrl-0 = <&mmc1_pins_default>;
 | ||||
| +	pinctrl-1 = <&mmc1_pins_uhs>;
 | ||||
| +	status = "okay";
 | ||||
| +	bus-width = <4>;
 | ||||
| +	max-frequency = <50000000>;
 | ||||
| +	cap-sd-highspeed;
 | ||||
| +	cd-gpios = <&pio 261 0>;
 | ||||
| +	vmmc-supply = <&mt6323_vmch_reg>;
 | ||||
| +	vqmmc-supply = <&mt6323_vio18_reg>;
 | ||||
| +};
 | ||||
| +
 | ||||
| +&pio {
 | ||||
| +	cir_pins_a:cir@0 {
 | ||||
| +		pins_cir {
 | ||||
| +			pinmux = <MT7623_PIN_46_IR_FUNC_IR>;
 | ||||
| +			bias-disable;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	i2c0_pins_a: i2c@0 {
 | ||||
| +		pins_i2c0 {
 | ||||
| +			pinmux = <MT7623_PIN_75_SDA0_FUNC_SDA0>,
 | ||||
| +				 <MT7623_PIN_76_SCL0_FUNC_SCL0>;
 | ||||
| +			bias-disable;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	i2c1_pins_a: i2c@1 {
 | ||||
| +		pin_i2c1 {
 | ||||
| +			pinmux = <MT7623_PIN_57_SDA1_FUNC_SDA1>,
 | ||||
| +				 <MT7623_PIN_58_SCL1_FUNC_SCL1>;
 | ||||
| +			bias-disable;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	i2s0_pins_a: i2s@0 {
 | ||||
| +		pin_i2s0 {
 | ||||
| +			pinmux = <MT7623_PIN_49_I2S0_DATA_FUNC_I2S0_DATA>,
 | ||||
| +				 <MT7623_PIN_72_I2S0_DATA_IN_FUNC_I2S0_DATA_IN>,
 | ||||
| +				 <MT7623_PIN_73_I2S0_LRCK_FUNC_I2S0_LRCK>,
 | ||||
| +				 <MT7623_PIN_74_I2S0_BCK_FUNC_I2S0_BCK>,
 | ||||
| +				 <MT7623_PIN_126_I2S0_MCLK_FUNC_I2S0_MCLK>;
 | ||||
| +			drive-strength = <MTK_DRIVE_12mA>;
 | ||||
| +			bias-pull-down;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	i2s1_pins_a: i2s@1 {
 | ||||
| +		pin_i2s1 {
 | ||||
| +			pinmux = <MT7623_PIN_33_I2S1_DATA_FUNC_I2S1_DATA>,
 | ||||
| +				 <MT7623_PIN_34_I2S1_DATA_IN_FUNC_I2S1_DATA_IN>,
 | ||||
| +				 <MT7623_PIN_35_I2S1_BCK_FUNC_I2S1_BCK>,
 | ||||
| +				 <MT7623_PIN_36_I2S1_LRCK_FUNC_I2S1_LRCK>,
 | ||||
| +				 <MT7623_PIN_37_I2S1_MCLK_FUNC_I2S1_MCLK>;
 | ||||
| +			drive-strength = <MTK_DRIVE_12mA>;
 | ||||
| +			bias-pull-down;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mmc0_pins_default: mmc0default {
 | ||||
| +		pins_cmd_dat {
 | ||||
| +			pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
 | ||||
| +				 <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
 | ||||
| +				 <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
 | ||||
| +				 <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
 | ||||
| +				 <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
 | ||||
| +				 <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
 | ||||
| +				 <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
 | ||||
| +				 <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
 | ||||
| +				 <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
 | ||||
| +			input-enable;
 | ||||
| +			bias-pull-up;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_clk {
 | ||||
| +			pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
 | ||||
| +			bias-pull-down;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_rst {
 | ||||
| +			pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
 | ||||
| +			bias-pull-up;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mmc0_pins_uhs: mmc0 {
 | ||||
| +		pins_cmd_dat {
 | ||||
| +			pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
 | ||||
| +				 <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
 | ||||
| +				 <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
 | ||||
| +				 <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
 | ||||
| +				 <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
 | ||||
| +				 <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
 | ||||
| +				 <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
 | ||||
| +				 <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
 | ||||
| +				 <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
 | ||||
| +			input-enable;
 | ||||
| +			drive-strength = <MTK_DRIVE_2mA>;
 | ||||
| +			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_clk {
 | ||||
| +			pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
 | ||||
| +			drive-strength = <MTK_DRIVE_2mA>;
 | ||||
| +			bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_rst {
 | ||||
| +			pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
 | ||||
| +			bias-pull-up;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mmc1_pins_default: mmc1default {
 | ||||
| +		pins_cmd_dat {
 | ||||
| +			pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
 | ||||
| +				 <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
 | ||||
| +				 <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
 | ||||
| +				 <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
 | ||||
| +				 <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
 | ||||
| +			input-enable;
 | ||||
| +			drive-strength = <MTK_DRIVE_4mA>;
 | ||||
| +			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_clk {
 | ||||
| +			pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
 | ||||
| +			bias-pull-down;
 | ||||
| +			drive-strength = <MTK_DRIVE_4mA>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_wp {
 | ||||
| +			pinmux = <MT7623_PIN_29_EINT7_FUNC_MSDC1_WP>;
 | ||||
| +			input-enable;
 | ||||
| +			bias-pull-up;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_insert {
 | ||||
| +			pinmux = <MT7623_PIN_261_MSDC1_INS_FUNC_GPIO261>;
 | ||||
| +			bias-pull-up;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	mmc1_pins_uhs: mmc1 {
 | ||||
| +		pins_cmd_dat {
 | ||||
| +			pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
 | ||||
| +				 <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
 | ||||
| +				 <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
 | ||||
| +				 <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
 | ||||
| +				 <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
 | ||||
| +			input-enable;
 | ||||
| +			drive-strength = <MTK_DRIVE_4mA>;
 | ||||
| +			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
 | ||||
| +		};
 | ||||
| +
 | ||||
| +		pins_clk {
 | ||||
| +			pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
 | ||||
| +			drive-strength = <MTK_DRIVE_4mA>;
 | ||||
| +			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	pwm_pins_a: pwm@0 {
 | ||||
| +		pins_pwm {
 | ||||
| +			pinmux = <MT7623_PIN_203_PWM0_FUNC_PWM0>,
 | ||||
| +				 <MT7623_PIN_204_PWM1_FUNC_PWM1>,
 | ||||
| +				 <MT7623_PIN_205_PWM2_FUNC_PWM2>,
 | ||||
| +				 <MT7623_PIN_206_PWM3_FUNC_PWM3>,
 | ||||
| +				 <MT7623_PIN_207_PWM4_FUNC_PWM4>;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	spi0_pins_a: spi@0 {
 | ||||
| +		pins_spi {
 | ||||
| +			pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
 | ||||
| +				<MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
 | ||||
| +				<MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
 | ||||
| +				<MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
 | ||||
| +			bias-disable;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	uart0_pins_a: uart@0 {
 | ||||
| +		pins_dat {
 | ||||
| +			pinmux = <MT7623_PIN_79_URXD0_FUNC_URXD0>,
 | ||||
| +				 <MT7623_PIN_80_UTXD0_FUNC_UTXD0>;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +
 | ||||
| +	uart1_pins_a: uart@1 {
 | ||||
| +		pins_dat {
 | ||||
| +			pinmux = <MT7623_PIN_81_URXD1_FUNC_URXD1>,
 | ||||
| +				 <MT7623_PIN_82_UTXD1_FUNC_UTXD1>;
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +
 | ||||
| +&pwm {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&pwm_pins_a>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&pwrap {
 | ||||
| +	mt6323 {
 | ||||
| +		mt6323led: led {
 | ||||
| +			compatible = "mediatek,mt6323-led";
 | ||||
| +			#address-cells = <1>;
 | ||||
| +			#size-cells = <0>;
 | ||||
| +
 | ||||
| +			led@0 {
 | ||||
| +				reg = <0>;
 | ||||
| +				label = "bpi-r2:isink:green";
 | ||||
| +				default-state = "off";
 | ||||
| +			};
 | ||||
| +
 | ||||
| +			led@1 {
 | ||||
| +				reg = <1>;
 | ||||
| +				label = "bpi-r2:isink:red";
 | ||||
| +				default-state = "off";
 | ||||
| +			};
 | ||||
| +
 | ||||
| +			led@2 {
 | ||||
| +				reg = <2>;
 | ||||
| +				label = "bpi-r2:isink:blue";
 | ||||
| +				default-state = "off";
 | ||||
| +			};
 | ||||
| +		};
 | ||||
| +	};
 | ||||
| +};
 | ||||
| +
 | ||||
| +&spi0 {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&spi0_pins_a>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&uart0 {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&uart0_pins_a>;
 | ||||
| +	status = "disabled";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&uart1 {
 | ||||
| +	pinctrl-names = "default";
 | ||||
| +	pinctrl-0 = <&uart1_pins_a>;
 | ||||
| +	status = "disabled";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&uart2 {
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&usb1 {
 | ||||
| +	vusb33-supply = <&mt6323_vusb_reg>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&usb2 {
 | ||||
| +	vusb33-supply = <&mt6323_vusb_reg>;
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&u3phy1 {
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| +&u3phy2 {
 | ||||
| +	status = "okay";
 | ||||
| +};
 | ||||
| +
 | ||||
| --- a/arch/arm/boot/dts/mt7623.dtsi
 | ||||
| +++ b/arch/arm/boot/dts/mt7623.dtsi
 | ||||
| @@ -323,6 +323,7 @@
 | ||||
|  			     "syscon"; | ||||
|  		reg = <0 0x10209000 0 0x1000>; | ||||
|  		#clock-cells = <1>; | ||||
| +		#reset-cells = <1>;
 | ||||
|  	}; | ||||
|   | ||||
|  	rng: rng@1020f000 { | ||||
|  | @ -0,0 +1,114 @@ | |||
| From 5d6a82632eb7258c8ca49cc96c18b8b4071b6639 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 20 Sep 2017 17:40:16 +0800 | ||||
| Subject: [PATCH 101/224] reset: mediatek: add reset controller dt-bindings | ||||
|  required header for MT7622 SoC | ||||
| 
 | ||||
| Add the reset controller dt-bindings exported from infracfg, pericfg, | ||||
| hifsys and ethsys which could be found on MT7622 SoC. So that we can | ||||
| reference them from within a device-tree file. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> | ||||
| ---
 | ||||
|  include/dt-bindings/reset/mt7622-reset.h | 94 ++++++++++++++++++++++++++++++++ | ||||
|  1 file changed, 94 insertions(+) | ||||
|  create mode 100644 include/dt-bindings/reset/mt7622-reset.h | ||||
| 
 | ||||
| --- /dev/null
 | ||||
| +++ b/include/dt-bindings/reset/mt7622-reset.h
 | ||||
| @@ -0,0 +1,94 @@
 | ||||
| +/*
 | ||||
| + * Copyright (c) 2017 MediaTek Inc.
 | ||||
| + * Author: Sean Wang <sean.wang@mediatek.com>
 | ||||
| + *
 | ||||
| + * This program is free software; you can redistribute it and/or modify
 | ||||
| + * it under the terms of the GNU General Public License version 2 as
 | ||||
| + * published by the Free Software Foundation.
 | ||||
| + *
 | ||||
| + * 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.
 | ||||
| + */
 | ||||
| +
 | ||||
| +#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT7622
 | ||||
| +#define _DT_BINDINGS_RESET_CONTROLLER_MT7622
 | ||||
| +
 | ||||
| +/* INFRACFG resets */
 | ||||
| +#define MT7622_INFRA_EMI_REG_RST		0
 | ||||
| +#define MT7622_INFRA_DRAMC0_A0_RST		1
 | ||||
| +#define MT7622_INFRA_APCIRQ_EINT_RST		3
 | ||||
| +#define MT7622_INFRA_APXGPT_RST			4
 | ||||
| +#define MT7622_INFRA_SCPSYS_RST			5
 | ||||
| +#define MT7622_INFRA_PMIC_WRAP_RST		7
 | ||||
| +#define MT7622_INFRA_IRRX_RST			9
 | ||||
| +#define MT7622_INFRA_EMI_RST			16
 | ||||
| +#define MT7622_INFRA_WED0_RST			17
 | ||||
| +#define MT7622_INFRA_DRAMC_RST			18
 | ||||
| +#define MT7622_INFRA_CCI_INTF_RST		19
 | ||||
| +#define MT7622_INFRA_TRNG_RST			21
 | ||||
| +#define MT7622_INFRA_SYSIRQ_RST			22
 | ||||
| +#define MT7622_INFRA_WED1_RST			25
 | ||||
| +
 | ||||
| +/* PERICFG Subsystem resets */
 | ||||
| +#define MT7622_PERI_UART0_SW_RST		0
 | ||||
| +#define MT7622_PERI_UART1_SW_RST		1
 | ||||
| +#define MT7622_PERI_UART2_SW_RST		2
 | ||||
| +#define MT7622_PERI_UART3_SW_RST		3
 | ||||
| +#define MT7622_PERI_UART4_SW_RST		4
 | ||||
| +#define MT7622_PERI_BTIF_SW_RST			6
 | ||||
| +#define MT7622_PERI_PWM_SW_RST			8
 | ||||
| +#define MT7622_PERI_AUXADC_SW_RST		10
 | ||||
| +#define MT7622_PERI_DMA_SW_RST			11
 | ||||
| +#define MT7622_PERI_IRTX_SW_RST			13
 | ||||
| +#define MT7622_PERI_NFI_SW_RST			14
 | ||||
| +#define MT7622_PERI_THERM_SW_RST		16
 | ||||
| +#define MT7622_PERI_MSDC0_SW_RST		19
 | ||||
| +#define MT7622_PERI_MSDC1_SW_RST		20
 | ||||
| +#define MT7622_PERI_I2C0_SW_RST			22
 | ||||
| +#define MT7622_PERI_I2C1_SW_RST			23
 | ||||
| +#define MT7622_PERI_I2C2_SW_RST			24
 | ||||
| +#define MT7622_PERI_SPI0_SW_RST			33
 | ||||
| +#define MT7622_PERI_SPI1_SW_RST			34
 | ||||
| +#define MT7622_PERI_FLASHIF_SW_RST		36
 | ||||
| +
 | ||||
| +/* TOPRGU resets */
 | ||||
| +#define MT7622_TOPRGU_INFRA_RST			0
 | ||||
| +#define MT7622_TOPRGU_ETHDMA_RST		1
 | ||||
| +#define MT7622_TOPRGU_DDRPHY_RST		6
 | ||||
| +#define MT7622_TOPRGU_INFRA_AO_RST		8
 | ||||
| +#define MT7622_TOPRGU_CONN_RST			9
 | ||||
| +#define MT7622_TOPRGU_APMIXED_RST		10
 | ||||
| +#define MT7622_TOPRGU_CONN_MCU_RST		12
 | ||||
| +
 | ||||
| +/* PCIe/SATA Subsystem resets */
 | ||||
| +#define MT7622_SATA_PHY_REG_RST			12
 | ||||
| +#define MT7622_SATA_PHY_SW_RST			13
 | ||||
| +#define MT7622_SATA_AXI_BUS_RST			15
 | ||||
| +#define MT7622_PCIE1_CORE_RST			19
 | ||||
| +#define MT7622_PCIE1_MMIO_RST			20
 | ||||
| +#define MT7622_PCIE1_HRST			21
 | ||||
| +#define MT7622_PCIE1_USER_RST			22
 | ||||
| +#define MT7622_PCIE1_PIPE_RST			23
 | ||||
| +#define MT7622_PCIE0_CORE_RST			27
 | ||||
| +#define MT7622_PCIE0_MMIO_RST			28
 | ||||
| +#define MT7622_PCIE0_HRST			29
 | ||||
| +#define MT7622_PCIE0_USER_RST			30
 | ||||
| +#define MT7622_PCIE0_PIPE_RST			31
 | ||||
| +
 | ||||
| +/* SSUSB Subsystem resets */
 | ||||
| +#define MT7622_SSUSB_PHY_PWR_RST		3
 | ||||
| +#define MT7622_SSUSB_MAC_PWR_RST		4
 | ||||
| +
 | ||||
| +/* ETHSYS Subsystem resets */
 | ||||
| +#define MT7622_ETHSYS_SYS_RST			0
 | ||||
| +#define MT7622_ETHSYS_MCM_RST			2
 | ||||
| +#define MT7622_ETHSYS_HSDMA_RST			5
 | ||||
| +#define MT7622_ETHSYS_FE_RST			6
 | ||||
| +#define MT7622_ETHSYS_GMAC_RST			23
 | ||||
| +#define MT7622_ETHSYS_EPHY_RST			24
 | ||||
| +#define MT7622_ETHSYS_CRYPTO_RST		29
 | ||||
| +#define MT7622_ETHSYS_PPE_RST			31
 | ||||
| +
 | ||||
| +#endif  /* _DT_BINDINGS_RESET_CONTROLLER_MT7622 */
 | ||||
|  | @ -0,0 +1,71 @@ | |||
| From c7cb4b7e750fc9a23cd80ef34ad4ef8a47f895d5 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Thu, 21 Sep 2017 16:26:57 +0800 | ||||
| Subject: [PATCH 102/224] soc: mediatek: pwrap: fixup warnings from coding | ||||
|  style | ||||
| 
 | ||||
| fixup those warnings such as lines over 80 words and parenthesis | ||||
| alignment which would be complained by checkpatch.pl. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 20 +++++++++++++------- | ||||
|  1 file changed, 13 insertions(+), 7 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -827,7 +827,8 @@ static int pwrap_init_cipher(struct pmic
 | ||||
|  	/* wait for cipher data ready@PMIC */ | ||||
|  	ret = pwrap_wait_for_state(wrp, pwrap_is_pmic_cipher_ready); | ||||
|  	if (ret) { | ||||
| -		dev_err(wrp->dev, "timeout waiting for cipher data ready@PMIC\n");
 | ||||
| +		dev_err(wrp->dev,
 | ||||
| +			"timeout waiting for cipher data ready@PMIC\n");
 | ||||
|  		return ret; | ||||
|  	} | ||||
|   | ||||
| @@ -1159,23 +1160,27 @@ static int pwrap_probe(struct platform_d
 | ||||
|  		if (IS_ERR(wrp->bridge_base)) | ||||
|  			return PTR_ERR(wrp->bridge_base); | ||||
|   | ||||
| -		wrp->rstc_bridge = devm_reset_control_get(wrp->dev, "pwrap-bridge");
 | ||||
| +		wrp->rstc_bridge = devm_reset_control_get(wrp->dev,
 | ||||
| +							  "pwrap-bridge");
 | ||||
|  		if (IS_ERR(wrp->rstc_bridge)) { | ||||
|  			ret = PTR_ERR(wrp->rstc_bridge); | ||||
| -			dev_dbg(wrp->dev, "cannot get pwrap-bridge reset: %d\n", ret);
 | ||||
| +			dev_dbg(wrp->dev,
 | ||||
| +				"cannot get pwrap-bridge reset: %d\n", ret);
 | ||||
|  			return ret; | ||||
|  		} | ||||
|  	} | ||||
|   | ||||
|  	wrp->clk_spi = devm_clk_get(wrp->dev, "spi"); | ||||
|  	if (IS_ERR(wrp->clk_spi)) { | ||||
| -		dev_dbg(wrp->dev, "failed to get clock: %ld\n", PTR_ERR(wrp->clk_spi));
 | ||||
| +		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
 | ||||
| +			PTR_ERR(wrp->clk_spi));
 | ||||
|  		return PTR_ERR(wrp->clk_spi); | ||||
|  	} | ||||
|   | ||||
|  	wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap"); | ||||
|  	if (IS_ERR(wrp->clk_wrap)) { | ||||
| -		dev_dbg(wrp->dev, "failed to get clock: %ld\n", PTR_ERR(wrp->clk_wrap));
 | ||||
| +		dev_dbg(wrp->dev, "failed to get clock: %ld\n",
 | ||||
| +			PTR_ERR(wrp->clk_wrap));
 | ||||
|  		return PTR_ERR(wrp->clk_wrap); | ||||
|  	} | ||||
|   | ||||
| @@ -1220,8 +1225,9 @@ static int pwrap_probe(struct platform_d
 | ||||
|  	pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN); | ||||
|   | ||||
|  	irq = platform_get_irq(pdev, 0); | ||||
| -	ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt, IRQF_TRIGGER_HIGH,
 | ||||
| -			"mt-pmic-pwrap", wrp);
 | ||||
| +	ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt,
 | ||||
| +			       IRQF_TRIGGER_HIGH,
 | ||||
| +			       "mt-pmic-pwrap", wrp);
 | ||||
|  	if (ret) | ||||
|  		goto err_out2; | ||||
|   | ||||
|  | @ -0,0 +1,108 @@ | |||
| From 7a46c3488c48a0fbe313ed25c12af3fb3af48a01 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:38 +0800 | ||||
| Subject: [PATCH 104/224] usb: mtu3: support option to disable usb3 ports | ||||
| 
 | ||||
| Add support to disable specific usb3 ports, it's useful when | ||||
| usb3 phy is shared with PCIe or SATA, because we should disable | ||||
| the corresponding usb3 port if the phy is used by PCIe or SATA. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h      |  3 +++ | ||||
|  drivers/usb/mtu3/mtu3_host.c | 16 +++++++++++++--- | ||||
|  drivers/usb/mtu3/mtu3_plat.c |  8 ++++++-- | ||||
|  3 files changed, 22 insertions(+), 5 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -210,6 +210,8 @@ struct otg_switch_mtk {
 | ||||
|   *		host only, device only or dual-role mode | ||||
|   * @u2_ports: number of usb2.0 host ports | ||||
|   * @u3_ports: number of usb3.0 host ports | ||||
| + * @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to
 | ||||
| + *		disable u3port0, bit1==1 to disable u3port1,... etc
 | ||||
|   * @dbgfs_root: only used when supports manual dual-role switch via debugfs | ||||
|   * @wakeup_en: it's true when supports remote wakeup in host mode | ||||
|   * @wk_deb_p0: port0's wakeup debounce clock | ||||
| @@ -232,6 +234,7 @@ struct ssusb_mtk {
 | ||||
|  	bool is_host; | ||||
|  	int u2_ports; | ||||
|  	int u3_ports; | ||||
| +	int u3p_dis_msk;
 | ||||
|  	struct dentry *dbgfs_root; | ||||
|  	/* usb wakeup for host mode */ | ||||
|  	bool wakeup_en; | ||||
| --- a/drivers/usb/mtu3/mtu3_host.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_host.c
 | ||||
| @@ -151,6 +151,7 @@ int ssusb_host_enable(struct ssusb_mtk *
 | ||||
|  	void __iomem *ibase = ssusb->ippc_base; | ||||
|  	int num_u3p = ssusb->u3_ports; | ||||
|  	int num_u2p = ssusb->u2_ports; | ||||
| +	int u3_ports_disabed;
 | ||||
|  	u32 check_clk; | ||||
|  	u32 value; | ||||
|  	int i; | ||||
| @@ -158,8 +159,14 @@ int ssusb_host_enable(struct ssusb_mtk *
 | ||||
|  	/* power on host ip */ | ||||
|  	mtu3_clrbits(ibase, U3D_SSUSB_IP_PW_CTRL1, SSUSB_IP_HOST_PDN); | ||||
|   | ||||
| -	/* power on and enable all u3 ports */
 | ||||
| +	/* power on and enable u3 ports except skipped ones */
 | ||||
| +	u3_ports_disabed = 0;
 | ||||
|  	for (i = 0; i < num_u3p; i++) { | ||||
| +		if ((0x1 << i) & ssusb->u3p_dis_msk) {
 | ||||
| +			u3_ports_disabed++;
 | ||||
| +			continue;
 | ||||
| +		}
 | ||||
| +
 | ||||
|  		value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); | ||||
|  		value &= ~(SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_DIS); | ||||
|  		value |= SSUSB_U3_PORT_HOST_SEL; | ||||
| @@ -175,7 +182,7 @@ int ssusb_host_enable(struct ssusb_mtk *
 | ||||
|  	} | ||||
|   | ||||
|  	check_clk = SSUSB_XHCI_RST_B_STS; | ||||
| -	if (num_u3p)
 | ||||
| +	if (num_u3p > u3_ports_disabed)
 | ||||
|  		check_clk = SSUSB_U3_MAC_RST_B_STS; | ||||
|   | ||||
|  	return ssusb_check_clocks(ssusb, check_clk); | ||||
| @@ -190,8 +197,11 @@ int ssusb_host_disable(struct ssusb_mtk
 | ||||
|  	int ret; | ||||
|  	int i; | ||||
|   | ||||
| -	/* power down and disable all u3 ports */
 | ||||
| +	/* power down and disable u3 ports except skipped ones */
 | ||||
|  	for (i = 0; i < num_u3p; i++) { | ||||
| +		if ((0x1 << i) & ssusb->u3p_dis_msk)
 | ||||
| +			continue;
 | ||||
| +
 | ||||
|  		value = mtu3_readl(ibase, SSUSB_U3_CTRL(i)); | ||||
|  		value |= SSUSB_U3_PORT_PDN; | ||||
|  		value |= suspend ? 0 : SSUSB_U3_PORT_DIS; | ||||
| --- a/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| @@ -276,6 +276,10 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  	if (ret) | ||||
|  		return ret; | ||||
|   | ||||
| +	/* optional property, ignore the error if it does not exist */
 | ||||
| +	of_property_read_u32(node, "mediatek,u3p-dis-msk",
 | ||||
| +			     &ssusb->u3p_dis_msk);
 | ||||
| +
 | ||||
|  	if (ssusb->dr_mode != USB_DR_MODE_OTG) | ||||
|  		return 0; | ||||
|   | ||||
| @@ -304,8 +308,8 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  		} | ||||
|  	} | ||||
|   | ||||
| -	dev_info(dev, "dr_mode: %d, is_u3_dr: %d\n",
 | ||||
| -		ssusb->dr_mode, otg_sx->is_u3_drd);
 | ||||
| +	dev_info(dev, "dr_mode: %d, is_u3_dr: %d, u3p_dis_msk:%x\n",
 | ||||
| +		ssusb->dr_mode, otg_sx->is_u3_drd, ssusb->u3p_dis_msk);
 | ||||
|   | ||||
|  	return 0; | ||||
|  } | ||||
|  | @ -0,0 +1,119 @@ | |||
| From 50005796f146351dc9c34bbf8898b305c562e964 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:39 +0800 | ||||
| Subject: [PATCH 105/224] usb: mtu3: remove dummy wakeup debounce clocks | ||||
| 
 | ||||
| The wakeup debounce clocks for each ports in fact are not | ||||
| needed, so remove them. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h      |  4 ---- | ||||
|  drivers/usb/mtu3/mtu3_host.c | 57 ++++---------------------------------------- | ||||
|  2 files changed, 4 insertions(+), 57 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -214,8 +214,6 @@ struct otg_switch_mtk {
 | ||||
|   *		disable u3port0, bit1==1 to disable u3port1,... etc | ||||
|   * @dbgfs_root: only used when supports manual dual-role switch via debugfs | ||||
|   * @wakeup_en: it's true when supports remote wakeup in host mode | ||||
| - * @wk_deb_p0: port0's wakeup debounce clock
 | ||||
| - * @wk_deb_p1: it's optional, and depends on port1 is supported or not
 | ||||
|   */ | ||||
|  struct ssusb_mtk { | ||||
|  	struct device *dev; | ||||
| @@ -238,8 +236,6 @@ struct ssusb_mtk {
 | ||||
|  	struct dentry *dbgfs_root; | ||||
|  	/* usb wakeup for host mode */ | ||||
|  	bool wakeup_en; | ||||
| -	struct clk *wk_deb_p0;
 | ||||
| -	struct clk *wk_deb_p1;
 | ||||
|  	struct regmap *pericfg; | ||||
|  }; | ||||
|   | ||||
| --- a/drivers/usb/mtu3/mtu3_host.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_host.c
 | ||||
| @@ -79,20 +79,6 @@ int ssusb_wakeup_of_property_parse(struc
 | ||||
|  	if (!ssusb->wakeup_en) | ||||
|  		return 0; | ||||
|   | ||||
| -	ssusb->wk_deb_p0 = devm_clk_get(dev, "wakeup_deb_p0");
 | ||||
| -	if (IS_ERR(ssusb->wk_deb_p0)) {
 | ||||
| -		dev_err(dev, "fail to get wakeup_deb_p0\n");
 | ||||
| -		return PTR_ERR(ssusb->wk_deb_p0);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	if (of_property_read_bool(dn, "wakeup_deb_p1")) {
 | ||||
| -		ssusb->wk_deb_p1 = devm_clk_get(dev, "wakeup_deb_p1");
 | ||||
| -		if (IS_ERR(ssusb->wk_deb_p1)) {
 | ||||
| -			dev_err(dev, "fail to get wakeup_deb_p1\n");
 | ||||
| -			return PTR_ERR(ssusb->wk_deb_p1);
 | ||||
| -		}
 | ||||
| -	}
 | ||||
| -
 | ||||
|  	ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn, | ||||
|  						"mediatek,syscon-wakeup"); | ||||
|  	if (IS_ERR(ssusb->pericfg)) { | ||||
| @@ -103,36 +89,6 @@ int ssusb_wakeup_of_property_parse(struc
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| -static int ssusb_wakeup_clks_enable(struct ssusb_mtk *ssusb)
 | ||||
| -{
 | ||||
| -	int ret;
 | ||||
| -
 | ||||
| -	ret = clk_prepare_enable(ssusb->wk_deb_p0);
 | ||||
| -	if (ret) {
 | ||||
| -		dev_err(ssusb->dev, "failed to enable wk_deb_p0\n");
 | ||||
| -		goto usb_p0_err;
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	ret = clk_prepare_enable(ssusb->wk_deb_p1);
 | ||||
| -	if (ret) {
 | ||||
| -		dev_err(ssusb->dev, "failed to enable wk_deb_p1\n");
 | ||||
| -		goto usb_p1_err;
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	return 0;
 | ||||
| -
 | ||||
| -usb_p1_err:
 | ||||
| -	clk_disable_unprepare(ssusb->wk_deb_p0);
 | ||||
| -usb_p0_err:
 | ||||
| -	return -EINVAL;
 | ||||
| -}
 | ||||
| -
 | ||||
| -static void ssusb_wakeup_clks_disable(struct ssusb_mtk *ssusb)
 | ||||
| -{
 | ||||
| -	clk_disable_unprepare(ssusb->wk_deb_p1);
 | ||||
| -	clk_disable_unprepare(ssusb->wk_deb_p0);
 | ||||
| -}
 | ||||
| -
 | ||||
|  static void host_ports_num_get(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
|  	u32 xhci_cap; | ||||
| @@ -286,19 +242,14 @@ void ssusb_host_exit(struct ssusb_mtk *s
 | ||||
|   | ||||
|  int ssusb_wakeup_enable(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
| -	int ret = 0;
 | ||||
| -
 | ||||
| -	if (ssusb->wakeup_en) {
 | ||||
| -		ret = ssusb_wakeup_clks_enable(ssusb);
 | ||||
| +	if (ssusb->wakeup_en)
 | ||||
|  		ssusb_wakeup_ip_sleep_en(ssusb); | ||||
| -	}
 | ||||
| -	return ret;
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
|  } | ||||
|   | ||||
|  void ssusb_wakeup_disable(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
| -	if (ssusb->wakeup_en) {
 | ||||
| +	if (ssusb->wakeup_en)
 | ||||
|  		ssusb_wakeup_ip_sleep_dis(ssusb); | ||||
| -		ssusb_wakeup_clks_disable(ssusb);
 | ||||
| -	}
 | ||||
|  } | ||||
|  | @ -0,0 +1,227 @@ | |||
| From 677805f6d83524717b46b3cde74aa455dbf6299f Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:40 +0800 | ||||
| Subject: [PATCH 106/224] usb: mtu3: add optional mcu and dma bus clocks | ||||
| 
 | ||||
| There are mcu_bus and dma_bus clocks needed to be turned on/off by | ||||
| driver on some SoCs, so add them as optional ones | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h      |   5 ++ | ||||
|  drivers/usb/mtu3/mtu3_plat.c | 121 +++++++++++++++++++++++++++++-------------- | ||||
|  2 files changed, 86 insertions(+), 40 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -206,6 +206,9 @@ struct otg_switch_mtk {
 | ||||
|   * @ippc_base: register base address of IP Power and Clock interface (IPPC) | ||||
|   * @vusb33: usb3.3V shared by device/host IP | ||||
|   * @sys_clk: system clock of mtu3, shared by device/host IP | ||||
| + * @ref_clk: reference clock
 | ||||
| + * @mcu_clk: mcu_bus_ck clock for AHB bus etc
 | ||||
| + * @dma_clk: dma_bus_ck clock for AXI bus etc
 | ||||
|   * @dr_mode: works in which mode: | ||||
|   *		host only, device only or dual-role mode | ||||
|   * @u2_ports: number of usb2.0 host ports | ||||
| @@ -226,6 +229,8 @@ struct ssusb_mtk {
 | ||||
|  	struct regulator *vusb33; | ||||
|  	struct clk *sys_clk; | ||||
|  	struct clk *ref_clk; | ||||
| +	struct clk *mcu_clk;
 | ||||
| +	struct clk *dma_clk;
 | ||||
|  	/* otg */ | ||||
|  	struct otg_switch_mtk otg_switch; | ||||
|  	enum usb_dr_mode dr_mode; | ||||
| --- a/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| @@ -110,15 +110,9 @@ static void ssusb_phy_power_off(struct s
 | ||||
|  		phy_power_off(ssusb->phys[i]); | ||||
|  } | ||||
|   | ||||
| -static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
 | ||||
| +static int ssusb_clks_enable(struct ssusb_mtk *ssusb)
 | ||||
|  { | ||||
| -	int ret = 0;
 | ||||
| -
 | ||||
| -	ret = regulator_enable(ssusb->vusb33);
 | ||||
| -	if (ret) {
 | ||||
| -		dev_err(ssusb->dev, "failed to enable vusb33\n");
 | ||||
| -		goto vusb33_err;
 | ||||
| -	}
 | ||||
| +	int ret;
 | ||||
|   | ||||
|  	ret = clk_prepare_enable(ssusb->sys_clk); | ||||
|  	if (ret) { | ||||
| @@ -132,6 +126,52 @@ static int ssusb_rscs_init(struct ssusb_
 | ||||
|  		goto ref_clk_err; | ||||
|  	} | ||||
|   | ||||
| +	ret = clk_prepare_enable(ssusb->mcu_clk);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(ssusb->dev, "failed to enable mcu_clk\n");
 | ||||
| +		goto mcu_clk_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	ret = clk_prepare_enable(ssusb->dma_clk);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(ssusb->dev, "failed to enable dma_clk\n");
 | ||||
| +		goto dma_clk_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +
 | ||||
| +dma_clk_err:
 | ||||
| +	clk_disable_unprepare(ssusb->mcu_clk);
 | ||||
| +mcu_clk_err:
 | ||||
| +	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| +ref_clk_err:
 | ||||
| +	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| +sys_clk_err:
 | ||||
| +	return ret;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void ssusb_clks_disable(struct ssusb_mtk *ssusb)
 | ||||
| +{
 | ||||
| +	clk_disable_unprepare(ssusb->dma_clk);
 | ||||
| +	clk_disable_unprepare(ssusb->mcu_clk);
 | ||||
| +	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| +	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
 | ||||
| +{
 | ||||
| +	int ret = 0;
 | ||||
| +
 | ||||
| +	ret = regulator_enable(ssusb->vusb33);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(ssusb->dev, "failed to enable vusb33\n");
 | ||||
| +		goto vusb33_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	ret = ssusb_clks_enable(ssusb);
 | ||||
| +	if (ret)
 | ||||
| +		goto clks_err;
 | ||||
| +
 | ||||
|  	ret = ssusb_phy_init(ssusb); | ||||
|  	if (ret) { | ||||
|  		dev_err(ssusb->dev, "failed to init phy\n"); | ||||
| @@ -149,20 +189,16 @@ static int ssusb_rscs_init(struct ssusb_
 | ||||
|  phy_err: | ||||
|  	ssusb_phy_exit(ssusb); | ||||
|  phy_init_err: | ||||
| -	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| -ref_clk_err:
 | ||||
| -	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| -sys_clk_err:
 | ||||
| +	ssusb_clks_disable(ssusb);
 | ||||
| +clks_err:
 | ||||
|  	regulator_disable(ssusb->vusb33); | ||||
|  vusb33_err: | ||||
| -
 | ||||
|  	return ret; | ||||
|  } | ||||
|   | ||||
|  static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
| -	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| -	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| +	ssusb_clks_disable(ssusb);
 | ||||
|  	regulator_disable(ssusb->vusb33); | ||||
|  	ssusb_phy_power_off(ssusb); | ||||
|  	ssusb_phy_exit(ssusb); | ||||
| @@ -203,6 +239,19 @@ static int get_iddig_pinctrl(struct ssus
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +/* ignore the error if the clock does not exist */
 | ||||
| +static struct clk *get_optional_clk(struct device *dev, const char *id)
 | ||||
| +{
 | ||||
| +	struct clk *opt_clk;
 | ||||
| +
 | ||||
| +	opt_clk = devm_clk_get(dev, id);
 | ||||
| +	/* ignore error number except EPROBE_DEFER */
 | ||||
| +	if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
 | ||||
| +		opt_clk = NULL;
 | ||||
| +
 | ||||
| +	return opt_clk;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) | ||||
|  { | ||||
|  	struct device_node *node = pdev->dev.of_node; | ||||
| @@ -225,18 +274,17 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  		return PTR_ERR(ssusb->sys_clk); | ||||
|  	} | ||||
|   | ||||
| -	/*
 | ||||
| -	 * reference clock is usually a "fixed-clock", make it optional
 | ||||
| -	 * for backward compatibility and ignore the error if it does
 | ||||
| -	 * not exist.
 | ||||
| -	 */
 | ||||
| -	ssusb->ref_clk = devm_clk_get(dev, "ref_ck");
 | ||||
| -	if (IS_ERR(ssusb->ref_clk)) {
 | ||||
| -		if (PTR_ERR(ssusb->ref_clk) == -EPROBE_DEFER)
 | ||||
| -			return -EPROBE_DEFER;
 | ||||
| -
 | ||||
| -		ssusb->ref_clk = NULL;
 | ||||
| -	}
 | ||||
| +	ssusb->ref_clk = get_optional_clk(dev, "ref_ck");
 | ||||
| +	if (IS_ERR(ssusb->ref_clk))
 | ||||
| +		return PTR_ERR(ssusb->ref_clk);
 | ||||
| +
 | ||||
| +	ssusb->mcu_clk = get_optional_clk(dev, "mcu_ck");
 | ||||
| +	if (IS_ERR(ssusb->mcu_clk))
 | ||||
| +		return PTR_ERR(ssusb->mcu_clk);
 | ||||
| +
 | ||||
| +	ssusb->dma_clk = get_optional_clk(dev, "dma_ck");
 | ||||
| +	if (IS_ERR(ssusb->dma_clk))
 | ||||
| +		return PTR_ERR(ssusb->dma_clk);
 | ||||
|   | ||||
|  	ssusb->num_phys = of_count_phandle_with_args(node, | ||||
|  			"phys", "#phy-cells"); | ||||
| @@ -451,8 +499,7 @@ static int __maybe_unused mtu3_suspend(s
 | ||||
|   | ||||
|  	ssusb_host_disable(ssusb, true); | ||||
|  	ssusb_phy_power_off(ssusb); | ||||
| -	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| -	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| +	ssusb_clks_disable(ssusb);
 | ||||
|  	ssusb_wakeup_enable(ssusb); | ||||
|   | ||||
|  	return 0; | ||||
| @@ -470,27 +517,21 @@ static int __maybe_unused mtu3_resume(st
 | ||||
|  		return 0; | ||||
|   | ||||
|  	ssusb_wakeup_disable(ssusb); | ||||
| -	ret = clk_prepare_enable(ssusb->sys_clk);
 | ||||
| -	if (ret)
 | ||||
| -		goto err_sys_clk;
 | ||||
| -
 | ||||
| -	ret = clk_prepare_enable(ssusb->ref_clk);
 | ||||
| +	ret = ssusb_clks_enable(ssusb);
 | ||||
|  	if (ret) | ||||
| -		goto err_ref_clk;
 | ||||
| +		goto clks_err;
 | ||||
|   | ||||
|  	ret = ssusb_phy_power_on(ssusb); | ||||
|  	if (ret) | ||||
| -		goto err_power_on;
 | ||||
| +		goto phy_err;
 | ||||
|   | ||||
|  	ssusb_host_enable(ssusb); | ||||
|   | ||||
|  	return 0; | ||||
|   | ||||
| -err_power_on:
 | ||||
| -	clk_disable_unprepare(ssusb->ref_clk);
 | ||||
| -err_ref_clk:
 | ||||
| -	clk_disable_unprepare(ssusb->sys_clk);
 | ||||
| -err_sys_clk:
 | ||||
| +phy_err:
 | ||||
| +	ssusb_clks_disable(ssusb);
 | ||||
| +clks_err:
 | ||||
|  	return ret; | ||||
|  } | ||||
|   | ||||
|  | @ -0,0 +1,362 @@ | |||
| From d366bf086a61b7a895d8819a3c1349b9c6b8e40f Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:41 +0800 | ||||
| Subject: [PATCH 107/224] usb: mtu3: support 36-bit DMA address | ||||
| 
 | ||||
| add support for 36-bit DMA address | ||||
| 
 | ||||
| [ Felipe Balbi: fix printk format for dma_addr_t ] | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h         |  17 ++++++- | ||||
|  drivers/usb/mtu3/mtu3_core.c    |  34 +++++++++++++- | ||||
|  drivers/usb/mtu3/mtu3_hw_regs.h |  10 ++++ | ||||
|  drivers/usb/mtu3/mtu3_qmu.c     | 102 +++++++++++++++++++++++++++++++++------- | ||||
|  4 files changed, 142 insertions(+), 21 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -46,6 +46,9 @@ struct mtu3_request;
 | ||||
|  #define	MU3D_EP_RXCR1(epnum)	(U3D_RX1CSR1 + (((epnum) - 1) * 0x10)) | ||||
|  #define	MU3D_EP_RXCR2(epnum)	(U3D_RX1CSR2 + (((epnum) - 1) * 0x10)) | ||||
|   | ||||
| +#define USB_QMU_TQHIAR(epnum)	(U3D_TXQHIAR1 + (((epnum) - 1) * 0x4))
 | ||||
| +#define USB_QMU_RQHIAR(epnum)	(U3D_RXQHIAR1 + (((epnum) - 1) * 0x4))
 | ||||
| +
 | ||||
|  #define USB_QMU_RQCSR(epnum)	(U3D_RXQCSR1 + (((epnum) - 1) * 0x10)) | ||||
|  #define USB_QMU_RQSAR(epnum)	(U3D_RXQSAR1 + (((epnum) - 1) * 0x10)) | ||||
|  #define USB_QMU_RQCPR(epnum)	(U3D_RXQCPR1 + (((epnum) - 1) * 0x10)) | ||||
| @@ -138,23 +141,33 @@ struct mtu3_fifo_info {
 | ||||
|   *	Checksum value is calculated over the 16 bytes of the GPD by default; | ||||
|   * @data_buf_len (RX ONLY): This value indicates the length of | ||||
|   *	the assigned data buffer | ||||
| + * @tx_ext_addr (TX ONLY): [3:0] are 4 extension bits of @buffer,
 | ||||
| + *	[7:4] are 4 extension bits of @next_gpd
 | ||||
|   * @next_gpd: Physical address of the next GPD | ||||
|   * @buffer: Physical address of the data buffer | ||||
|   * @buf_len: | ||||
|   *	(TX): This value indicates the length of the assigned data buffer | ||||
|   *	(RX): The total length of data received | ||||
|   * @ext_len: reserved | ||||
| + * @rx_ext_addr(RX ONLY): [3:0] are 4 extension bits of @buffer,
 | ||||
| + *	[7:4] are 4 extension bits of @next_gpd
 | ||||
|   * @ext_flag: | ||||
|   *	bit5 (TX ONLY): Zero Length Packet (ZLP), | ||||
|   */ | ||||
|  struct qmu_gpd { | ||||
|  	__u8 flag; | ||||
|  	__u8 chksum; | ||||
| -	__le16 data_buf_len;
 | ||||
| +	union {
 | ||||
| +		__le16 data_buf_len;
 | ||||
| +		__le16 tx_ext_addr;
 | ||||
| +	};
 | ||||
|  	__le32 next_gpd; | ||||
|  	__le32 buffer; | ||||
|  	__le16 buf_len; | ||||
| -	__u8 ext_len;
 | ||||
| +	union {
 | ||||
| +		__u8 ext_len;
 | ||||
| +		__u8 rx_ext_addr;
 | ||||
| +	};
 | ||||
|  	__u8 ext_flag; | ||||
|  } __packed; | ||||
|   | ||||
| --- a/drivers/usb/mtu3/mtu3_core.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_core.c
 | ||||
| @@ -17,6 +17,7 @@
 | ||||
|   * | ||||
|   */ | ||||
|   | ||||
| +#include <linux/dma-mapping.h>
 | ||||
|  #include <linux/kernel.h> | ||||
|  #include <linux/module.h> | ||||
|  #include <linux/of_address.h> | ||||
| @@ -759,7 +760,31 @@ static void mtu3_hw_exit(struct mtu3 *mt
 | ||||
|  	mtu3_mem_free(mtu); | ||||
|  } | ||||
|   | ||||
| -/*-------------------------------------------------------------------------*/
 | ||||
| +/**
 | ||||
| + * we set 32-bit DMA mask by default, here check whether the controller
 | ||||
| + * supports 36-bit DMA or not, if it does, set 36-bit DMA mask.
 | ||||
| + */
 | ||||
| +static int mtu3_set_dma_mask(struct mtu3 *mtu)
 | ||||
| +{
 | ||||
| +	struct device *dev = mtu->dev;
 | ||||
| +	bool is_36bit = false;
 | ||||
| +	int ret = 0;
 | ||||
| +	u32 value;
 | ||||
| +
 | ||||
| +	value = mtu3_readl(mtu->mac_base, U3D_MISC_CTRL);
 | ||||
| +	if (value & DMA_ADDR_36BIT) {
 | ||||
| +		is_36bit = true;
 | ||||
| +		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(36));
 | ||||
| +		/* If set 36-bit DMA mask fails, fall back to 32-bit DMA mask */
 | ||||
| +		if (ret) {
 | ||||
| +			is_36bit = false;
 | ||||
| +			ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
 | ||||
| +		}
 | ||||
| +	}
 | ||||
| +	dev_info(dev, "dma mask: %s bits\n", is_36bit ? "36" : "32");
 | ||||
| +
 | ||||
| +	return ret;
 | ||||
| +}
 | ||||
|   | ||||
|  int ssusb_gadget_init(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
| @@ -820,6 +845,12 @@ int ssusb_gadget_init(struct ssusb_mtk *
 | ||||
|  		return ret; | ||||
|  	} | ||||
|   | ||||
| +	ret = mtu3_set_dma_mask(mtu);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(dev, "mtu3 set dma_mask failed:%d\n", ret);
 | ||||
| +		goto dma_mask_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	ret = devm_request_irq(dev, mtu->irq, mtu3_irq, 0, dev_name(dev), mtu); | ||||
|  	if (ret) { | ||||
|  		dev_err(dev, "request irq %d failed!\n", mtu->irq); | ||||
| @@ -845,6 +876,7 @@ int ssusb_gadget_init(struct ssusb_mtk *
 | ||||
|  gadget_err: | ||||
|  	device_init_wakeup(dev, false); | ||||
|   | ||||
| +dma_mask_err:
 | ||||
|  irq_err: | ||||
|  	mtu3_hw_exit(mtu); | ||||
|  	ssusb->u3d = NULL; | ||||
| --- a/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| @@ -58,6 +58,8 @@
 | ||||
|  #define U3D_QCR1		(SSUSB_DEV_BASE + 0x0404) | ||||
|  #define U3D_QCR2		(SSUSB_DEV_BASE + 0x0408) | ||||
|  #define U3D_QCR3		(SSUSB_DEV_BASE + 0x040C) | ||||
| +#define U3D_TXQHIAR1		(SSUSB_DEV_BASE + 0x0484)
 | ||||
| +#define U3D_RXQHIAR1		(SSUSB_DEV_BASE + 0x04C4)
 | ||||
|   | ||||
|  #define U3D_TXQCSR1		(SSUSB_DEV_BASE + 0x0510) | ||||
|  #define U3D_TXQSAR1		(SSUSB_DEV_BASE + 0x0514) | ||||
| @@ -189,6 +191,13 @@
 | ||||
|  #define QMU_RX_COZ(x)		(BIT(16) << (x)) | ||||
|  #define QMU_RX_ZLP(x)		(BIT(0) << (x)) | ||||
|   | ||||
| +/* U3D_TXQHIAR1 */
 | ||||
| +/* U3D_RXQHIAR1 */
 | ||||
| +#define QMU_LAST_DONE_PTR_HI(x)	(((x) >> 16) & 0xf)
 | ||||
| +#define QMU_CUR_GPD_ADDR_HI(x)	(((x) >> 8) & 0xf)
 | ||||
| +#define QMU_START_ADDR_HI_MSK	GENMASK(3, 0)
 | ||||
| +#define QMU_START_ADDR_HI(x)	(((x) & 0xf) << 0)
 | ||||
| +
 | ||||
|  /* U3D_TXQCSR1 */ | ||||
|  /* U3D_RXQCSR1 */ | ||||
|  #define QMU_Q_ACTIVE		BIT(15) | ||||
| @@ -225,6 +234,7 @@
 | ||||
|  #define CAP_TX_EP_NUM(x)	((x) & 0x1f) | ||||
|   | ||||
|  /* U3D_MISC_CTRL */ | ||||
| +#define DMA_ADDR_36BIT		BIT(31)
 | ||||
|  #define VBUS_ON			BIT(1) | ||||
|  #define VBUS_FRC_EN		BIT(0) | ||||
|   | ||||
| --- a/drivers/usb/mtu3/mtu3_qmu.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_qmu.c
 | ||||
| @@ -40,7 +40,58 @@
 | ||||
|  #define GPD_FLAGS_IOC	BIT(7) | ||||
|   | ||||
|  #define GPD_EXT_FLAG_ZLP	BIT(5) | ||||
| +#define GPD_EXT_NGP(x)		(((x) & 0xf) << 4)
 | ||||
| +#define GPD_EXT_BUF(x)		(((x) & 0xf) << 0)
 | ||||
|   | ||||
| +#define HILO_GEN64(hi, lo) (((u64)(hi) << 32) + (lo))
 | ||||
| +#define HILO_DMA(hi, lo)	\
 | ||||
| +	((dma_addr_t)HILO_GEN64((le32_to_cpu(hi)), (le32_to_cpu(lo))))
 | ||||
| +
 | ||||
| +static dma_addr_t read_txq_cur_addr(void __iomem *mbase, u8 epnum)
 | ||||
| +{
 | ||||
| +	u32 txcpr;
 | ||||
| +	u32 txhiar;
 | ||||
| +
 | ||||
| +	txcpr = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
 | ||||
| +	txhiar = mtu3_readl(mbase, USB_QMU_TQHIAR(epnum));
 | ||||
| +
 | ||||
| +	return HILO_DMA(QMU_CUR_GPD_ADDR_HI(txhiar), txcpr);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static dma_addr_t read_rxq_cur_addr(void __iomem *mbase, u8 epnum)
 | ||||
| +{
 | ||||
| +	u32 rxcpr;
 | ||||
| +	u32 rxhiar;
 | ||||
| +
 | ||||
| +	rxcpr = mtu3_readl(mbase, USB_QMU_RQCPR(epnum));
 | ||||
| +	rxhiar = mtu3_readl(mbase, USB_QMU_RQHIAR(epnum));
 | ||||
| +
 | ||||
| +	return HILO_DMA(QMU_CUR_GPD_ADDR_HI(rxhiar), rxcpr);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void write_txq_start_addr(void __iomem *mbase, u8 epnum, dma_addr_t dma)
 | ||||
| +{
 | ||||
| +	u32 tqhiar;
 | ||||
| +
 | ||||
| +	mtu3_writel(mbase, USB_QMU_TQSAR(epnum),
 | ||||
| +		    cpu_to_le32(lower_32_bits(dma)));
 | ||||
| +	tqhiar = mtu3_readl(mbase, USB_QMU_TQHIAR(epnum));
 | ||||
| +	tqhiar &= ~QMU_START_ADDR_HI_MSK;
 | ||||
| +	tqhiar |= QMU_START_ADDR_HI(upper_32_bits(dma));
 | ||||
| +	mtu3_writel(mbase, USB_QMU_TQHIAR(epnum), tqhiar);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void write_rxq_start_addr(void __iomem *mbase, u8 epnum, dma_addr_t dma)
 | ||||
| +{
 | ||||
| +	u32 rqhiar;
 | ||||
| +
 | ||||
| +	mtu3_writel(mbase, USB_QMU_RQSAR(epnum),
 | ||||
| +		    cpu_to_le32(lower_32_bits(dma)));
 | ||||
| +	rqhiar = mtu3_readl(mbase, USB_QMU_RQHIAR(epnum));
 | ||||
| +	rqhiar &= ~QMU_START_ADDR_HI_MSK;
 | ||||
| +	rqhiar |= QMU_START_ADDR_HI(upper_32_bits(dma));
 | ||||
| +	mtu3_writel(mbase, USB_QMU_RQHIAR(epnum), rqhiar);
 | ||||
| +}
 | ||||
|   | ||||
|  static struct qmu_gpd *gpd_dma_to_virt(struct mtu3_gpd_ring *ring, | ||||
|  		dma_addr_t dma_addr) | ||||
| @@ -193,21 +244,27 @@ static int mtu3_prepare_tx_gpd(struct mt
 | ||||
|  	struct mtu3_gpd_ring *ring = &mep->gpd_ring; | ||||
|  	struct qmu_gpd *gpd = ring->enqueue; | ||||
|  	struct usb_request *req = &mreq->request; | ||||
| +	dma_addr_t enq_dma;
 | ||||
| +	u16 ext_addr;
 | ||||
|   | ||||
|  	/* set all fields to zero as default value */ | ||||
|  	memset(gpd, 0, sizeof(*gpd)); | ||||
|   | ||||
| -	gpd->buffer = cpu_to_le32((u32)req->dma);
 | ||||
| +	gpd->buffer = cpu_to_le32(lower_32_bits(req->dma));
 | ||||
| +	ext_addr = GPD_EXT_BUF(upper_32_bits(req->dma));
 | ||||
|  	gpd->buf_len = cpu_to_le16(req->length); | ||||
|  	gpd->flag |= GPD_FLAGS_IOC; | ||||
|   | ||||
|  	/* get the next GPD */ | ||||
|  	enq = advance_enq_gpd(ring); | ||||
| -	dev_dbg(mep->mtu->dev, "TX-EP%d queue gpd=%p, enq=%p\n",
 | ||||
| -		mep->epnum, gpd, enq);
 | ||||
| +	enq_dma = gpd_virt_to_dma(ring, enq);
 | ||||
| +	dev_dbg(mep->mtu->dev, "TX-EP%d queue gpd=%p, enq=%p, qdma=%pad\n",
 | ||||
| +		mep->epnum, gpd, enq, enq_dma);
 | ||||
|   | ||||
|  	enq->flag &= ~GPD_FLAGS_HWO; | ||||
| -	gpd->next_gpd = cpu_to_le32((u32)gpd_virt_to_dma(ring, enq));
 | ||||
| +	gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
 | ||||
| +	ext_addr |= GPD_EXT_NGP(upper_32_bits(enq_dma));
 | ||||
| +	gpd->tx_ext_addr = cpu_to_le16(ext_addr);
 | ||||
|   | ||||
|  	if (req->zero) | ||||
|  		gpd->ext_flag |= GPD_EXT_FLAG_ZLP; | ||||
| @@ -226,21 +283,27 @@ static int mtu3_prepare_rx_gpd(struct mt
 | ||||
|  	struct mtu3_gpd_ring *ring = &mep->gpd_ring; | ||||
|  	struct qmu_gpd *gpd = ring->enqueue; | ||||
|  	struct usb_request *req = &mreq->request; | ||||
| +	dma_addr_t enq_dma;
 | ||||
| +	u16 ext_addr;
 | ||||
|   | ||||
|  	/* set all fields to zero as default value */ | ||||
|  	memset(gpd, 0, sizeof(*gpd)); | ||||
|   | ||||
| -	gpd->buffer = cpu_to_le32((u32)req->dma);
 | ||||
| +	gpd->buffer = cpu_to_le32(lower_32_bits(req->dma));
 | ||||
| +	ext_addr = GPD_EXT_BUF(upper_32_bits(req->dma));
 | ||||
|  	gpd->data_buf_len = cpu_to_le16(req->length); | ||||
|  	gpd->flag |= GPD_FLAGS_IOC; | ||||
|   | ||||
|  	/* get the next GPD */ | ||||
|  	enq = advance_enq_gpd(ring); | ||||
| -	dev_dbg(mep->mtu->dev, "RX-EP%d queue gpd=%p, enq=%p\n",
 | ||||
| -		mep->epnum, gpd, enq);
 | ||||
| +	enq_dma = gpd_virt_to_dma(ring, enq);
 | ||||
| +	dev_dbg(mep->mtu->dev, "RX-EP%d queue gpd=%p, enq=%p, qdma=%pad\n",
 | ||||
| +		mep->epnum, gpd, enq, enq_dma);
 | ||||
|   | ||||
|  	enq->flag &= ~GPD_FLAGS_HWO; | ||||
| -	gpd->next_gpd = cpu_to_le32((u32)gpd_virt_to_dma(ring, enq));
 | ||||
| +	gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
 | ||||
| +	ext_addr |= GPD_EXT_NGP(upper_32_bits(enq_dma));
 | ||||
| +	gpd->rx_ext_addr = cpu_to_le16(ext_addr);
 | ||||
|  	gpd->chksum = qmu_calc_checksum((u8 *)gpd); | ||||
|  	gpd->flag |= GPD_FLAGS_HWO; | ||||
|   | ||||
| @@ -267,8 +330,8 @@ int mtu3_qmu_start(struct mtu3_ep *mep)
 | ||||
|   | ||||
|  	if (mep->is_in) { | ||||
|  		/* set QMU start address */ | ||||
| -		mtu3_writel(mbase, USB_QMU_TQSAR(mep->epnum), ring->dma);
 | ||||
| -		mtu3_setbits(mbase, MU3D_EP_TXCR0(mep->epnum), TX_DMAREQEN);
 | ||||
| +		write_txq_start_addr(mbase, epnum, ring->dma);
 | ||||
| +		mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_DMAREQEN);
 | ||||
|  		mtu3_setbits(mbase, U3D_QCR0, QMU_TX_CS_EN(epnum)); | ||||
|  		/* send zero length packet according to ZLP flag in GPD */ | ||||
|  		mtu3_setbits(mbase, U3D_QCR1, QMU_TX_ZLP(epnum)); | ||||
| @@ -282,8 +345,8 @@ int mtu3_qmu_start(struct mtu3_ep *mep)
 | ||||
|  		mtu3_writel(mbase, USB_QMU_TQCSR(epnum), QMU_Q_START); | ||||
|   | ||||
|  	} else { | ||||
| -		mtu3_writel(mbase, USB_QMU_RQSAR(mep->epnum), ring->dma);
 | ||||
| -		mtu3_setbits(mbase, MU3D_EP_RXCR0(mep->epnum), RX_DMAREQEN);
 | ||||
| +		write_rxq_start_addr(mbase, epnum, ring->dma);
 | ||||
| +		mtu3_setbits(mbase, MU3D_EP_RXCR0(epnum), RX_DMAREQEN);
 | ||||
|  		mtu3_setbits(mbase, U3D_QCR0, QMU_RX_CS_EN(epnum)); | ||||
|  		/* don't expect ZLP */ | ||||
|  		mtu3_clrbits(mbase, U3D_QCR3, QMU_RX_ZLP(epnum)); | ||||
| @@ -353,9 +416,9 @@ static void qmu_tx_zlp_error_handler(str
 | ||||
|  	struct mtu3_gpd_ring *ring = &mep->gpd_ring; | ||||
|  	void __iomem *mbase = mtu->mac_base; | ||||
|  	struct qmu_gpd *gpd_current = NULL; | ||||
| -	dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
 | ||||
|  	struct usb_request *req = NULL; | ||||
|  	struct mtu3_request *mreq; | ||||
| +	dma_addr_t cur_gpd_dma;
 | ||||
|  	u32 txcsr = 0; | ||||
|  	int ret; | ||||
|   | ||||
| @@ -365,7 +428,8 @@ static void qmu_tx_zlp_error_handler(str
 | ||||
|  	else | ||||
|  		return; | ||||
|   | ||||
| -	gpd_current = gpd_dma_to_virt(ring, gpd_dma);
 | ||||
| +	cur_gpd_dma = read_txq_cur_addr(mbase, epnum);
 | ||||
| +	gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
 | ||||
|   | ||||
|  	if (le16_to_cpu(gpd_current->buf_len) != 0) { | ||||
|  		dev_err(mtu->dev, "TX EP%d buffer length error(!=0)\n", epnum); | ||||
| @@ -408,12 +472,13 @@ static void qmu_done_tx(struct mtu3 *mtu
 | ||||
|  	void __iomem *mbase = mtu->mac_base; | ||||
|  	struct qmu_gpd *gpd = ring->dequeue; | ||||
|  	struct qmu_gpd *gpd_current = NULL; | ||||
| -	dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_TQCPR(epnum));
 | ||||
|  	struct usb_request *request = NULL; | ||||
|  	struct mtu3_request *mreq; | ||||
| +	dma_addr_t cur_gpd_dma;
 | ||||
|   | ||||
|  	/*transfer phy address got from QMU register to virtual address */ | ||||
| -	gpd_current = gpd_dma_to_virt(ring, gpd_dma);
 | ||||
| +	cur_gpd_dma = read_txq_cur_addr(mbase, epnum);
 | ||||
| +	gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
 | ||||
|   | ||||
|  	dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", | ||||
|  		__func__, epnum, gpd, gpd_current, ring->enqueue); | ||||
| @@ -446,11 +511,12 @@ static void qmu_done_rx(struct mtu3 *mtu
 | ||||
|  	void __iomem *mbase = mtu->mac_base; | ||||
|  	struct qmu_gpd *gpd = ring->dequeue; | ||||
|  	struct qmu_gpd *gpd_current = NULL; | ||||
| -	dma_addr_t gpd_dma = mtu3_readl(mbase, USB_QMU_RQCPR(epnum));
 | ||||
|  	struct usb_request *req = NULL; | ||||
|  	struct mtu3_request *mreq; | ||||
| +	dma_addr_t cur_gpd_dma;
 | ||||
|   | ||||
| -	gpd_current = gpd_dma_to_virt(ring, gpd_dma);
 | ||||
| +	cur_gpd_dma = read_rxq_cur_addr(mbase, epnum);
 | ||||
| +	gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma);
 | ||||
|   | ||||
|  	dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", | ||||
|  		__func__, epnum, gpd, gpd_current, ring->enqueue); | ||||
|  | @ -0,0 +1,274 @@ | |||
| From 6c4995c9a8ba8841ba640201636954c84f494587 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:42 +0800 | ||||
| Subject: [PATCH 108/224] usb: mtu3: use FORCE/RG_IDDIG to implement manual DRD | ||||
|  switch | ||||
| 
 | ||||
| In order to keep manual DRD switch independent on IDDIG interrupt, | ||||
| make use of FORCE/RG_IDDIG instead of IDDIG EINT interrupt to | ||||
| implement manual DRD switch function. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h         | 18 ++++++++---- | ||||
|  drivers/usb/mtu3/mtu3_dr.c      | 61 ++++++++++++++++++++++++++++++----------- | ||||
|  drivers/usb/mtu3/mtu3_dr.h      |  6 ++++ | ||||
|  drivers/usb/mtu3/mtu3_host.c    |  5 ++++ | ||||
|  drivers/usb/mtu3/mtu3_hw_regs.h |  2 ++ | ||||
|  drivers/usb/mtu3/mtu3_plat.c    | 38 ++----------------------- | ||||
|  6 files changed, 74 insertions(+), 56 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -115,6 +115,19 @@ enum mtu3_g_ep0_state {
 | ||||
|  }; | ||||
|   | ||||
|  /** | ||||
| + * MTU3_DR_FORCE_NONE: automatically switch host and periperal mode
 | ||||
| + *		by IDPIN signal.
 | ||||
| + * MTU3_DR_FORCE_HOST: force to enter host mode and override OTG
 | ||||
| + *		IDPIN signal.
 | ||||
| + * MTU3_DR_FORCE_DEVICE: force to enter peripheral mode.
 | ||||
| + */
 | ||||
| +enum mtu3_dr_force_mode {
 | ||||
| +	MTU3_DR_FORCE_NONE = 0,
 | ||||
| +	MTU3_DR_FORCE_HOST,
 | ||||
| +	MTU3_DR_FORCE_DEVICE,
 | ||||
| +};
 | ||||
| +
 | ||||
| +/**
 | ||||
|   * @base: the base address of fifo | ||||
|   * @limit: the bitmap size in bits | ||||
|   * @bitmap: fifo bitmap in unit of @MTU3_EP_FIFO_UNIT | ||||
| @@ -196,7 +209,6 @@ struct mtu3_gpd_ring {
 | ||||
|  *		xHCI driver initialization, it's necessary for system bootup | ||||
|  *		as device. | ||||
|  * @is_u3_drd: whether port0 supports usb3.0 dual-role device or not | ||||
| -* @id_*: used to maually switch between host and device modes by idpin
 | ||||
|  * @manual_drd_enabled: it's true when supports dual-role device by debugfs | ||||
|  *		to switch host/device modes depending on user input. | ||||
|  */ | ||||
| @@ -207,10 +219,6 @@ struct otg_switch_mtk {
 | ||||
|  	struct notifier_block id_nb; | ||||
|  	struct delayed_work extcon_reg_dwork; | ||||
|  	bool is_u3_drd; | ||||
| -	/* dual-role switch by debugfs */
 | ||||
| -	struct pinctrl *id_pinctrl;
 | ||||
| -	struct pinctrl_state *id_float;
 | ||||
| -	struct pinctrl_state *id_ground;
 | ||||
|  	bool manual_drd_enabled; | ||||
|  }; | ||||
|   | ||||
| --- a/drivers/usb/mtu3/mtu3_dr.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_dr.c
 | ||||
| @@ -261,21 +261,22 @@ static void extcon_register_dwork(struct
 | ||||
|   * depending on user input. | ||||
|   * This is useful in special cases, such as uses TYPE-A receptacle but also | ||||
|   * wants to support dual-role mode. | ||||
| - * It generates cable state changes by pulling up/down IDPIN and
 | ||||
| - * notifies driver to switch mode by "extcon-usb-gpio".
 | ||||
| - * NOTE: when use MICRO receptacle, should not enable this interface.
 | ||||
|   */ | ||||
|  static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host) | ||||
|  { | ||||
|  	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; | ||||
|   | ||||
| -	if (to_host)
 | ||||
| -		pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_ground);
 | ||||
| -	else
 | ||||
| -		pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_float);
 | ||||
| +	if (to_host) {
 | ||||
| +		ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_HOST);
 | ||||
| +		ssusb_set_mailbox(otg_sx, MTU3_VBUS_OFF);
 | ||||
| +		ssusb_set_mailbox(otg_sx, MTU3_ID_GROUND);
 | ||||
| +	} else {
 | ||||
| +		ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_DEVICE);
 | ||||
| +		ssusb_set_mailbox(otg_sx, MTU3_ID_FLOAT);
 | ||||
| +		ssusb_set_mailbox(otg_sx, MTU3_VBUS_VALID);
 | ||||
| +	}
 | ||||
|  } | ||||
|   | ||||
| -
 | ||||
|  static int ssusb_mode_show(struct seq_file *sf, void *unused) | ||||
|  { | ||||
|  	struct ssusb_mtk *ssusb = sf->private; | ||||
| @@ -388,17 +389,45 @@ static void ssusb_debugfs_exit(struct ss
 | ||||
|  	debugfs_remove_recursive(ssusb->dbgfs_root); | ||||
|  } | ||||
|   | ||||
| +void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
 | ||||
| +			  enum mtu3_dr_force_mode mode)
 | ||||
| +{
 | ||||
| +	u32 value;
 | ||||
| +
 | ||||
| +	value = mtu3_readl(ssusb->ippc_base, SSUSB_U2_CTRL(0));
 | ||||
| +	switch (mode) {
 | ||||
| +	case MTU3_DR_FORCE_DEVICE:
 | ||||
| +		value |= SSUSB_U2_PORT_FORCE_IDDIG | SSUSB_U2_PORT_RG_IDDIG;
 | ||||
| +		break;
 | ||||
| +	case MTU3_DR_FORCE_HOST:
 | ||||
| +		value |= SSUSB_U2_PORT_FORCE_IDDIG;
 | ||||
| +		value &= ~SSUSB_U2_PORT_RG_IDDIG;
 | ||||
| +		break;
 | ||||
| +	case MTU3_DR_FORCE_NONE:
 | ||||
| +		value &= ~(SSUSB_U2_PORT_FORCE_IDDIG | SSUSB_U2_PORT_RG_IDDIG);
 | ||||
| +		break;
 | ||||
| +	default:
 | ||||
| +		return;
 | ||||
| +	}
 | ||||
| +	mtu3_writel(ssusb->ippc_base, SSUSB_U2_CTRL(0), value);
 | ||||
| +}
 | ||||
| +
 | ||||
|  int ssusb_otg_switch_init(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
|  	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; | ||||
|   | ||||
| -	INIT_DELAYED_WORK(&otg_sx->extcon_reg_dwork, extcon_register_dwork);
 | ||||
| -
 | ||||
| -	if (otg_sx->manual_drd_enabled)
 | ||||
| +	if (otg_sx->manual_drd_enabled) {
 | ||||
|  		ssusb_debugfs_init(ssusb); | ||||
| +	} else {
 | ||||
| +		INIT_DELAYED_WORK(&otg_sx->extcon_reg_dwork,
 | ||||
| +				  extcon_register_dwork);
 | ||||
|   | ||||
| -	/* It is enough to delay 1s for waiting for host initialization */
 | ||||
| -	schedule_delayed_work(&otg_sx->extcon_reg_dwork, HZ);
 | ||||
| +		/*
 | ||||
| +		 * It is enough to delay 1s for waiting for
 | ||||
| +		 * host initialization
 | ||||
| +		 */
 | ||||
| +		schedule_delayed_work(&otg_sx->extcon_reg_dwork, HZ);
 | ||||
| +	}
 | ||||
|   | ||||
|  	return 0; | ||||
|  } | ||||
| @@ -407,8 +436,8 @@ void ssusb_otg_switch_exit(struct ssusb_
 | ||||
|  { | ||||
|  	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; | ||||
|   | ||||
| -	cancel_delayed_work(&otg_sx->extcon_reg_dwork);
 | ||||
| -
 | ||||
|  	if (otg_sx->manual_drd_enabled) | ||||
|  		ssusb_debugfs_exit(ssusb); | ||||
| +	else
 | ||||
| +		cancel_delayed_work(&otg_sx->extcon_reg_dwork);
 | ||||
|  } | ||||
| --- a/drivers/usb/mtu3/mtu3_dr.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_dr.h
 | ||||
| @@ -87,6 +87,8 @@ static inline void ssusb_gadget_exit(str
 | ||||
|  int ssusb_otg_switch_init(struct ssusb_mtk *ssusb); | ||||
|  void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb); | ||||
|  int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on); | ||||
| +void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
 | ||||
| +			  enum mtu3_dr_force_mode mode);
 | ||||
|   | ||||
|  #else | ||||
|   | ||||
| @@ -103,6 +105,10 @@ static inline int ssusb_set_vbus(struct
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static inline void
 | ||||
| +ssusb_set_force_mode(struct ssusb_mtk *ssusb, enum mtu3_dr_force_mode mode)
 | ||||
| +{}
 | ||||
| +
 | ||||
|  #endif | ||||
|   | ||||
|  #endif		/* _MTU3_DR_H_ */ | ||||
| --- a/drivers/usb/mtu3/mtu3_host.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_host.c
 | ||||
| @@ -189,6 +189,8 @@ int ssusb_host_disable(struct ssusb_mtk
 | ||||
|   | ||||
|  static void ssusb_host_setup(struct ssusb_mtk *ssusb) | ||||
|  { | ||||
| +	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
 | ||||
| +
 | ||||
|  	host_ports_num_get(ssusb); | ||||
|   | ||||
|  	/* | ||||
| @@ -197,6 +199,9 @@ static void ssusb_host_setup(struct ssus
 | ||||
|  	 */ | ||||
|  	ssusb_host_enable(ssusb); | ||||
|   | ||||
| +	if (otg_sx->manual_drd_enabled)
 | ||||
| +		ssusb_set_force_mode(ssusb, MTU3_DR_FORCE_HOST);
 | ||||
| +
 | ||||
|  	/* if port0 supports dual-role, works as host mode by default */ | ||||
|  	ssusb_set_vbus(&ssusb->otg_switch, 1); | ||||
|  } | ||||
| --- a/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| @@ -472,6 +472,8 @@
 | ||||
|  #define SSUSB_U3_PORT_DIS		BIT(0) | ||||
|   | ||||
|  /* U3D_SSUSB_U2_CTRL_0P */ | ||||
| +#define SSUSB_U2_PORT_RG_IDDIG		BIT(12)
 | ||||
| +#define SSUSB_U2_PORT_FORCE_IDDIG	BIT(11)
 | ||||
|  #define SSUSB_U2_PORT_VBUSVALID	BIT(9) | ||||
|  #define SSUSB_U2_PORT_OTG_SEL		BIT(7) | ||||
|  #define SSUSB_U2_PORT_HOST		BIT(2) | ||||
| --- a/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| @@ -21,7 +21,6 @@
 | ||||
|  #include <linux/module.h> | ||||
|  #include <linux/of_address.h> | ||||
|  #include <linux/of_irq.h> | ||||
| -#include <linux/pinctrl/consumer.h>
 | ||||
|  #include <linux/platform_device.h> | ||||
|   | ||||
|  #include "mtu3.h" | ||||
| @@ -212,33 +211,6 @@ static void ssusb_ip_sw_reset(struct ssu
 | ||||
|  	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST); | ||||
|  } | ||||
|   | ||||
| -static int get_iddig_pinctrl(struct ssusb_mtk *ssusb)
 | ||||
| -{
 | ||||
| -	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
 | ||||
| -
 | ||||
| -	otg_sx->id_pinctrl = devm_pinctrl_get(ssusb->dev);
 | ||||
| -	if (IS_ERR(otg_sx->id_pinctrl)) {
 | ||||
| -		dev_err(ssusb->dev, "Cannot find id pinctrl!\n");
 | ||||
| -		return PTR_ERR(otg_sx->id_pinctrl);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	otg_sx->id_float =
 | ||||
| -		pinctrl_lookup_state(otg_sx->id_pinctrl, "id_float");
 | ||||
| -	if (IS_ERR(otg_sx->id_float)) {
 | ||||
| -		dev_err(ssusb->dev, "Cannot find pinctrl id_float!\n");
 | ||||
| -		return PTR_ERR(otg_sx->id_float);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	otg_sx->id_ground =
 | ||||
| -		pinctrl_lookup_state(otg_sx->id_pinctrl, "id_ground");
 | ||||
| -	if (IS_ERR(otg_sx->id_ground)) {
 | ||||
| -		dev_err(ssusb->dev, "Cannot find pinctrl id_ground!\n");
 | ||||
| -		return PTR_ERR(otg_sx->id_ground);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	return 0;
 | ||||
| -}
 | ||||
| -
 | ||||
|  /* ignore the error if the clock does not exist */ | ||||
|  static struct clk *get_optional_clk(struct device *dev, const char *id) | ||||
|  { | ||||
| @@ -349,15 +321,11 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  			dev_err(ssusb->dev, "couldn't get extcon device\n"); | ||||
|  			return -EPROBE_DEFER; | ||||
|  		} | ||||
| -		if (otg_sx->manual_drd_enabled) {
 | ||||
| -			ret = get_iddig_pinctrl(ssusb);
 | ||||
| -			if (ret)
 | ||||
| -				return ret;
 | ||||
| -		}
 | ||||
|  	} | ||||
|   | ||||
| -	dev_info(dev, "dr_mode: %d, is_u3_dr: %d, u3p_dis_msk:%x\n",
 | ||||
| -		ssusb->dr_mode, otg_sx->is_u3_drd, ssusb->u3p_dis_msk);
 | ||||
| +	dev_info(dev, "dr_mode: %d, is_u3_dr: %d, u3p_dis_msk: %x, drd: %s\n",
 | ||||
| +		ssusb->dr_mode, otg_sx->is_u3_drd, ssusb->u3p_dis_msk,
 | ||||
| +		otg_sx->manual_drd_enabled ? "manual" : "auto");
 | ||||
|   | ||||
|  	return 0; | ||||
|  } | ||||
|  | @ -0,0 +1,152 @@ | |||
| From 8f444887e23b9f0ea31aaae74fbc18171714d8d2 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:43 +0800 | ||||
| Subject: [PATCH 109/224] usb: mtu3: add support for usb3.1 IP | ||||
| 
 | ||||
| Support SuperSpeedPlus for usb3.1 device IP | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3.h            |  1 + | ||||
|  drivers/usb/mtu3/mtu3_core.c       | 14 +++++++++++--- | ||||
|  drivers/usb/mtu3/mtu3_gadget.c     |  3 ++- | ||||
|  drivers/usb/mtu3/mtu3_gadget_ep0.c | 16 ++++++++-------- | ||||
|  drivers/usb/mtu3/mtu3_hw_regs.h    |  1 + | ||||
|  5 files changed, 23 insertions(+), 12 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3.h
 | ||||
| @@ -94,6 +94,7 @@ enum mtu3_speed {
 | ||||
|  	MTU3_SPEED_FULL = 1, | ||||
|  	MTU3_SPEED_HIGH = 3, | ||||
|  	MTU3_SPEED_SUPER = 4, | ||||
| +	MTU3_SPEED_SUPER_PLUS = 5,
 | ||||
|  }; | ||||
|   | ||||
|  /** | ||||
| --- a/drivers/usb/mtu3/mtu3_core.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_core.c
 | ||||
| @@ -237,7 +237,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *m
 | ||||
|   | ||||
|  void mtu3_dev_on_off(struct mtu3 *mtu, int is_on) | ||||
|  { | ||||
| -	if (mtu->is_u3_ip && (mtu->max_speed == USB_SPEED_SUPER))
 | ||||
| +	if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER)
 | ||||
|  		mtu3_ss_func_set(mtu, is_on); | ||||
|  	else | ||||
|  		mtu3_hs_softconn_set(mtu, is_on); | ||||
| @@ -547,6 +547,9 @@ static void mtu3_set_speed(struct mtu3 *
 | ||||
|  		mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); | ||||
|  		/* HS/FS detected by HW */ | ||||
|  		mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); | ||||
| +	} else if (mtu->max_speed == USB_SPEED_SUPER) {
 | ||||
| +		mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0),
 | ||||
| +			     SSUSB_U3_PORT_SSP_SPEED);
 | ||||
|  	} | ||||
|   | ||||
|  	dev_info(mtu->dev, "max_speed: %s\n", | ||||
| @@ -624,6 +627,10 @@ static irqreturn_t mtu3_link_isr(struct
 | ||||
|  		udev_speed = USB_SPEED_SUPER; | ||||
|  		maxpkt = 512; | ||||
|  		break; | ||||
| +	case MTU3_SPEED_SUPER_PLUS:
 | ||||
| +		udev_speed = USB_SPEED_SUPER_PLUS;
 | ||||
| +		maxpkt = 512;
 | ||||
| +		break;
 | ||||
|  	default: | ||||
|  		udev_speed = USB_SPEED_UNKNOWN; | ||||
|  		break; | ||||
| @@ -825,14 +832,15 @@ int ssusb_gadget_init(struct ssusb_mtk *
 | ||||
|  	case USB_SPEED_FULL: | ||||
|  	case USB_SPEED_HIGH: | ||||
|  	case USB_SPEED_SUPER: | ||||
| +	case USB_SPEED_SUPER_PLUS:
 | ||||
|  		break; | ||||
|  	default: | ||||
|  		dev_err(dev, "invalid max_speed: %s\n", | ||||
|  			usb_speed_string(mtu->max_speed)); | ||||
|  		/* fall through */ | ||||
|  	case USB_SPEED_UNKNOWN: | ||||
| -		/* default as SS */
 | ||||
| -		mtu->max_speed = USB_SPEED_SUPER;
 | ||||
| +		/* default as SSP */
 | ||||
| +		mtu->max_speed = USB_SPEED_SUPER_PLUS;
 | ||||
|  		break; | ||||
|  	} | ||||
|   | ||||
| --- a/drivers/usb/mtu3/mtu3_gadget.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_gadget.c
 | ||||
| @@ -89,6 +89,7 @@ static int mtu3_ep_enable(struct mtu3_ep
 | ||||
|   | ||||
|  	switch (mtu->g.speed) { | ||||
|  	case USB_SPEED_SUPER: | ||||
| +	case USB_SPEED_SUPER_PLUS:
 | ||||
|  		if (usb_endpoint_xfer_int(desc) || | ||||
|  				usb_endpoint_xfer_isoc(desc)) { | ||||
|  			interval = desc->bInterval; | ||||
| @@ -456,7 +457,7 @@ static int mtu3_gadget_wakeup(struct usb
 | ||||
|  		return  -EOPNOTSUPP; | ||||
|   | ||||
|  	spin_lock_irqsave(&mtu->lock, flags); | ||||
| -	if (mtu->g.speed == USB_SPEED_SUPER) {
 | ||||
| +	if (mtu->g.speed >= USB_SPEED_SUPER) {
 | ||||
|  		mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); | ||||
|  	} else { | ||||
|  		mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); | ||||
| --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c
 | ||||
| @@ -212,8 +212,8 @@ ep0_get_status(struct mtu3 *mtu, const s
 | ||||
|  	case USB_RECIP_DEVICE: | ||||
|  		result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED; | ||||
|  		result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; | ||||
| -		/* superspeed only */
 | ||||
| -		if (mtu->g.speed == USB_SPEED_SUPER) {
 | ||||
| +
 | ||||
| +		if (mtu->g.speed >= USB_SPEED_SUPER) {
 | ||||
|  			result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED; | ||||
|  			result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED; | ||||
|  		} | ||||
| @@ -329,8 +329,8 @@ static int ep0_handle_feature_dev(struct
 | ||||
|  		handled = handle_test_mode(mtu, setup); | ||||
|  		break; | ||||
|  	case USB_DEVICE_U1_ENABLE: | ||||
| -		if (mtu->g.speed != USB_SPEED_SUPER ||
 | ||||
| -			mtu->g.state != USB_STATE_CONFIGURED)
 | ||||
| +		if (mtu->g.speed < USB_SPEED_SUPER ||
 | ||||
| +		    mtu->g.state != USB_STATE_CONFIGURED)
 | ||||
|  			break; | ||||
|   | ||||
|  		lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); | ||||
| @@ -344,8 +344,8 @@ static int ep0_handle_feature_dev(struct
 | ||||
|  		handled = 1; | ||||
|  		break; | ||||
|  	case USB_DEVICE_U2_ENABLE: | ||||
| -		if (mtu->g.speed != USB_SPEED_SUPER ||
 | ||||
| -			mtu->g.state != USB_STATE_CONFIGURED)
 | ||||
| +		if (mtu->g.speed < USB_SPEED_SUPER ||
 | ||||
| +		    mtu->g.state != USB_STATE_CONFIGURED)
 | ||||
|  			break; | ||||
|   | ||||
|  		lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); | ||||
| @@ -384,8 +384,8 @@ static int ep0_handle_feature(struct mtu
 | ||||
|  		break; | ||||
|  	case USB_RECIP_INTERFACE: | ||||
|  		/* superspeed only */ | ||||
| -		if ((value == USB_INTRF_FUNC_SUSPEND)
 | ||||
| -			&& (mtu->g.speed == USB_SPEED_SUPER)) {
 | ||||
| +		if (value == USB_INTRF_FUNC_SUSPEND &&
 | ||||
| +		    mtu->g.speed >= USB_SPEED_SUPER) {
 | ||||
|  			/* | ||||
|  			 * forward the request because function drivers | ||||
|  			 * should handle it | ||||
| --- a/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_hw_regs.h
 | ||||
| @@ -467,6 +467,7 @@
 | ||||
|  #define SSUSB_VBUS_CHG_INT_B_EN		BIT(6) | ||||
|   | ||||
|  /* U3D_SSUSB_U3_CTRL_0P */ | ||||
| +#define SSUSB_U3_PORT_SSP_SPEED	BIT(9)
 | ||||
|  #define SSUSB_U3_PORT_HOST_SEL		BIT(2) | ||||
|  #define SSUSB_U3_PORT_PDN		BIT(1) | ||||
|  #define SSUSB_U3_PORT_DIS		BIT(0) | ||||
|  | @ -0,0 +1,40 @@ | |||
| From b6712b72d1273e792ee8a533048ba731a3709163 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:44 +0800 | ||||
| Subject: [PATCH 110/224] usb: mtu3: get optional vbus for host only mode | ||||
| 
 | ||||
| When dr_mode is set as USB_DR_MODE_HOST, it's better to try to | ||||
| get optional vbus, this can increase flexibility, although we | ||||
| can set vbus as always on for regulator or put it in host driver | ||||
| to turn it on. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3_plat.c | 8 ++++---- | ||||
|  1 file changed, 4 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| @@ -300,10 +300,6 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  	of_property_read_u32(node, "mediatek,u3p-dis-msk", | ||||
|  			     &ssusb->u3p_dis_msk); | ||||
|   | ||||
| -	if (ssusb->dr_mode != USB_DR_MODE_OTG)
 | ||||
| -		return 0;
 | ||||
| -
 | ||||
| -	/* if dual-role mode is supported */
 | ||||
|  	vbus = devm_regulator_get(&pdev->dev, "vbus"); | ||||
|  	if (IS_ERR(vbus)) { | ||||
|  		dev_err(dev, "failed to get vbus\n"); | ||||
| @@ -311,6 +307,10 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  	} | ||||
|  	otg_sx->vbus = vbus; | ||||
|   | ||||
| +	if (ssusb->dr_mode == USB_DR_MODE_HOST)
 | ||||
| +		return 0;
 | ||||
| +
 | ||||
| +	/* if dual-role mode is supported */
 | ||||
|  	otg_sx->is_u3_drd = of_property_read_bool(node, "mediatek,usb3-drd"); | ||||
|  	otg_sx->manual_drd_enabled = | ||||
|  		of_property_read_bool(node, "enable-manual-drd"); | ||||
|  | @ -0,0 +1,29 @@ | |||
| From e315036cdbf8dad7cff4df9dfe8bcff2eddf2277 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:45 +0800 | ||||
| Subject: [PATCH 111/224] usb: mtu3: set invalid dr_mode as dual-role mode | ||||
| 
 | ||||
| Treat dr_mode of USB_DR_MODE_UNKNOWN as USB_DR_MODE_OTG to | ||||
| enhance functional robustness. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3_plat.c | 6 ++---- | ||||
|  1 file changed, 2 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_plat.c
 | ||||
| @@ -283,10 +283,8 @@ static int get_ssusb_rscs(struct platfor
 | ||||
|  		return PTR_ERR(ssusb->ippc_base); | ||||
|   | ||||
|  	ssusb->dr_mode = usb_get_dr_mode(dev); | ||||
| -	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN) {
 | ||||
| -		dev_err(dev, "dr_mode is error\n");
 | ||||
| -		return -EINVAL;
 | ||||
| -	}
 | ||||
| +	if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN)
 | ||||
| +		ssusb->dr_mode = USB_DR_MODE_OTG;
 | ||||
|   | ||||
|  	if (ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) | ||||
|  		return 0; | ||||
|  | @ -0,0 +1,44 @@ | |||
| From 36f70702b66cd3453b65d46b5c26ea87d8897363 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:46 +0800 | ||||
| Subject: [PATCH 112/224] usb: mtu3: set otg_sel for u2port only if works as | ||||
|  dual-role mode | ||||
| 
 | ||||
| When set otg_sel(SSUSB_U2_PORT_OTG_SEL) for u2port which supports | ||||
| dual-role mode, the controller will automatically switch mode | ||||
| between host and device according to IDDIG signal. But if the | ||||
| u2port only supports device mode, and no IDDIG pin is provided, | ||||
| setting otg_sel may cause failure of detection by host. | ||||
| So set it only for dual-role mode. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  drivers/usb/mtu3/mtu3_core.c | 9 +++++++-- | ||||
|  1 file changed, 7 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/mtu3/mtu3_core.c
 | ||||
| +++ b/drivers/usb/mtu3/mtu3_core.c
 | ||||
| @@ -115,7 +115,9 @@ static int mtu3_device_enable(struct mtu
 | ||||
|  	mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), | ||||
|  		(SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | | ||||
|  		SSUSB_U2_PORT_HOST_SEL)); | ||||
| -	mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
 | ||||
| +
 | ||||
| +	if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
 | ||||
| +		mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
 | ||||
|   | ||||
|  	return ssusb_check_clocks(mtu->ssusb, check_clk); | ||||
|  } | ||||
| @@ -130,7 +132,10 @@ static void mtu3_device_disable(struct m
 | ||||
|   | ||||
|  	mtu3_setbits(ibase, SSUSB_U2_CTRL(0), | ||||
|  		SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN); | ||||
| -	mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
 | ||||
| +
 | ||||
| +	if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
 | ||||
| +		mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
 | ||||
| +
 | ||||
|  	mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); | ||||
|  } | ||||
|   | ||||
|  | @ -0,0 +1,25 @@ | |||
| From 6b6f2c178ee2cd57713993e3cf0afbe4effb2578 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:47 +0800 | ||||
| Subject: [PATCH 113/224] dt-bindings: usb: mtu3: add a optional property to | ||||
|  disable u3ports | ||||
| 
 | ||||
| Add a new optional property to disable u3ports | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 2 ++ | ||||
|  1 file changed, 2 insertions(+) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| @@ -44,6 +44,8 @@ Optional properties:
 | ||||
|   - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode | ||||
|   - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup | ||||
|  	control register, it depends on "mediatek,enable-wakeup". | ||||
| + - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 | ||||
| +	bit1 for u3port1, ... etc;
 | ||||
|   | ||||
|  Sub-nodes: | ||||
|  The xhci should be added as subnode to mtu3 as shown in the following example | ||||
|  | @ -0,0 +1,41 @@ | |||
| From 2c90367440a0dbf9962e7a7f701b0e7a320d325a Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:48 +0800 | ||||
| Subject: [PATCH 114/224] dt-bindings: usb: mtu3: remove dummy clocks and add | ||||
|  optional ones | ||||
| 
 | ||||
| Remove dummy clocks for usb wakeup and add optional ones for | ||||
| mcu_bus and dma_bus bus. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 10 ++++------ | ||||
|  1 file changed, 4 insertions(+), 6 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| @@ -14,9 +14,9 @@ Required properties:
 | ||||
|   - vusb33-supply : regulator of USB avdd3.3v | ||||
|   - clocks : a list of phandle + clock-specifier pairs, one for each | ||||
|  	entry in clock-names | ||||
| - - clock-names : must contain "sys_ck" and "ref_ck" for clock of controller;
 | ||||
| -	"wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are
 | ||||
| -	depends on "mediatek,enable-wakeup"
 | ||||
| + - clock-names : must contain "sys_ck" for clock of controller,
 | ||||
| +	the following clocks are optional:
 | ||||
| +	"ref_ck", "mcu_ck" and "dam_ck";
 | ||||
|   - phys : a list of phandle + phy specifier pairs | ||||
|   - dr_mode : should be one of "host", "peripheral" or "otg", | ||||
|  	refer to usb/generic.txt | ||||
| @@ -65,9 +65,7 @@ ssusb: usb@11271000 {
 | ||||
|  	clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, | ||||
|  		 <&pericfg CLK_PERI_USB0>, | ||||
|  		 <&pericfg CLK_PERI_USB1>; | ||||
| -	clock-names = "sys_ck", "ref_ck",
 | ||||
| -		      "wakeup_deb_p0",
 | ||||
| -		      "wakeup_deb_p1";
 | ||||
| +	clock-names = "sys_ck", "ref_ck";
 | ||||
|  	vusb33-supply = <&mt6397_vusb_reg>; | ||||
|  	vbus-supply = <&usb_p0_vbus>; | ||||
|  	extcon = <&extcon_usb>; | ||||
|  | @ -0,0 +1,30 @@ | |||
| From df2f0d10213798a806c90bc06db6bed501e7bf7d Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 17:10:49 +0800 | ||||
| Subject: [PATCH 115/224] dt-bindings: usb: mtu3: remove optional pinctrls | ||||
| 
 | ||||
| Remove optional pinctrls due to using FORCE/RG_IDDIG to implement | ||||
| manual switch function. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 7 ++++--- | ||||
|  1 file changed, 4 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | ||||
| @@ -30,9 +30,10 @@ Optional properties:
 | ||||
|  	when supports dual-role mode. | ||||
|   - vbus-supply : reference to the VBUS regulator, needed when supports | ||||
|  	dual-role mode. | ||||
| - - pinctl-names : a pinctrl state named "default" must be defined,
 | ||||
| -	"id_float" and "id_ground" are optinal which depends on
 | ||||
| -	"mediatek,enable-manual-drd"
 | ||||
| + - pinctrl-names : a pinctrl state named "default" is optional, and need be
 | ||||
| +	defined if auto drd switch is enabled, that means the property dr_mode
 | ||||
| +	is set as "otg", and meanwhile the property "mediatek,enable-manual-drd"
 | ||||
| +	is not set.
 | ||||
|   - pinctrl-0 : pin control group | ||||
|  	See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt | ||||
|   | ||||
|  | @ -0,0 +1,38 @@ | |||
| From 1567cde49a0f2304e18c08e2ccd830e0686fc0a7 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:42 +0800 | ||||
| Subject: [PATCH 116/224] dt-bindings: arm: mediatek: add MT7622 string to the | ||||
|  PMIC wrapper doc | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | 6 +++++- | ||||
|  1 file changed, 5 insertions(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
 | ||||
| @@ -19,6 +19,7 @@ IP Pairing
 | ||||
|  Required properties in pwrap device node. | ||||
|  - compatible: | ||||
|  	"mediatek,mt2701-pwrap" for MT2701/7623 SoCs | ||||
| +	"mediatek,mt7622-pwrap" for MT7622 SoCs
 | ||||
|  	"mediatek,mt8135-pwrap" for MT8135 SoCs | ||||
|  	"mediatek,mt8173-pwrap" for MT8173 SoCs | ||||
|  - interrupts: IRQ for pwrap in SOC | ||||
| @@ -36,9 +37,12 @@ Required properties in pwrap device node
 | ||||
|  - clocks: Must contain an entry for each entry in clock-names. | ||||
|   | ||||
|  Optional properities: | ||||
| -- pmic: Mediatek PMIC MFD is the child device of pwrap
 | ||||
| +- pmic: Using either MediaTek PMIC MFD as the child device of pwrap
 | ||||
|    See the following for child node definitions: | ||||
|    Documentation/devicetree/bindings/mfd/mt6397.txt | ||||
| +  or the regulator-only device as the child device of pwrap, such as MT6380.
 | ||||
| +  See the following definitions for such kinds of devices.
 | ||||
| +  Documentation/devicetree/bindings/regulator/mt6380-regulator.txt
 | ||||
|   | ||||
|  Example: | ||||
|  	pwrap: pwrap@1000f000 { | ||||
|  | @ -0,0 +1,134 @@ | |||
| From 9c37953bd08daa3ca227098d763e980d1898add3 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:43 +0800 | ||||
| Subject: [PATCH 117/224] soc: mediatek: pwrap: add pwrap_read32 for reading in | ||||
|  32-bit mode | ||||
| 
 | ||||
| Some regulators such as MediaTek MT6380 has to be read in 32-bit mode. | ||||
| So the patch adds pwrap_read32, rename old pwrap_read into pwrap_read16 | ||||
| and one function pointer is introduced for increasing flexibility allowing | ||||
| the determination which mode is used by the pwrap slave detection through | ||||
| device tree. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 55 +++++++++++++++++++++++++++++++++++- | ||||
|  1 file changed, 54 insertions(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -487,6 +487,7 @@ static int mt8135_regs[] = {
 | ||||
|   | ||||
|  enum pmic_type { | ||||
|  	PMIC_MT6323, | ||||
| +	PMIC_MT6380,
 | ||||
|  	PMIC_MT6397, | ||||
|  }; | ||||
|   | ||||
| @@ -496,9 +497,16 @@ enum pwrap_type {
 | ||||
|  	PWRAP_MT8173, | ||||
|  }; | ||||
|   | ||||
| +struct pmic_wrapper;
 | ||||
|  struct pwrap_slv_type { | ||||
|  	const u32 *dew_regs; | ||||
|  	enum pmic_type type; | ||||
| +	/*
 | ||||
| +	 * pwrap operations are highly associated with the PMIC types,
 | ||||
| +	 * so the pointers added increases flexibility allowing determination
 | ||||
| +	 * which type is used by the detection through device tree.
 | ||||
| +	 */
 | ||||
| +	int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata);
 | ||||
|  }; | ||||
|   | ||||
|  struct pmic_wrapper { | ||||
| @@ -609,7 +617,7 @@ static int pwrap_write(struct pmic_wrapp
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| -static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
 | ||||
| +static int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
 | ||||
|  { | ||||
|  	int ret; | ||||
|   | ||||
| @@ -632,6 +640,39 @@ static int pwrap_read(struct pmic_wrappe
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
 | ||||
| +{
 | ||||
| +	int ret, msb;
 | ||||
| +
 | ||||
| +	*rdata = 0;
 | ||||
| +	for (msb = 0; msb < 2; msb++) {
 | ||||
| +		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
 | ||||
| +		if (ret) {
 | ||||
| +			pwrap_leave_fsm_vldclr(wrp);
 | ||||
| +			return ret;
 | ||||
| +		}
 | ||||
| +
 | ||||
| +		pwrap_writel(wrp, ((msb << 30) | (adr << 16)),
 | ||||
| +			     PWRAP_WACS2_CMD);
 | ||||
| +
 | ||||
| +		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr);
 | ||||
| +		if (ret)
 | ||||
| +			return ret;
 | ||||
| +
 | ||||
| +		*rdata += (PWRAP_GET_WACS_RDATA(pwrap_readl(wrp,
 | ||||
| +			   PWRAP_WACS2_RDATA)) << (16 * msb));
 | ||||
| +
 | ||||
| +		pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
 | ||||
| +{
 | ||||
| +	return wrp->slave->pwrap_read(wrp, adr, rdata);
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int pwrap_regmap_read(void *context, u32 adr, u32 *rdata) | ||||
|  { | ||||
|  	return pwrap_read(context, adr, rdata); | ||||
| @@ -752,6 +793,8 @@ static int pwrap_mt2701_init_reg_clock(s
 | ||||
|  		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START); | ||||
|  		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END); | ||||
|  		break; | ||||
| +	default:
 | ||||
| +		break;
 | ||||
|  	} | ||||
|   | ||||
|  	return 0; | ||||
| @@ -815,6 +858,8 @@ static int pwrap_init_cipher(struct pmic
 | ||||
|  		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], | ||||
|  			    0x1); | ||||
|  		break; | ||||
| +	default:
 | ||||
| +		break;
 | ||||
|  	} | ||||
|   | ||||
|  	/* wait for cipher data ready@AP */ | ||||
| @@ -1036,11 +1081,19 @@ static const struct regmap_config pwrap_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6323 = { | ||||
|  	.dew_regs = mt6323_regs, | ||||
|  	.type = PMIC_MT6323, | ||||
| +	.pwrap_read = pwrap_read16,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct pwrap_slv_type pmic_mt6380 = {
 | ||||
| +	.dew_regs = NULL,
 | ||||
| +	.type = PMIC_MT6380,
 | ||||
| +	.pwrap_read = pwrap_read32,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct pwrap_slv_type pmic_mt6397 = { | ||||
|  	.dew_regs = mt6397_regs, | ||||
|  	.type = PMIC_MT6397, | ||||
| +	.pwrap_read = pwrap_read16,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id of_slave_match_tbl[] = { | ||||
|  | @ -0,0 +1,132 @@ | |||
| From 635f800995e4ea2a18ce7520d816dab018ce091f Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:44 +0800 | ||||
| Subject: [PATCH 118/224] soc: mediatek: pwrap: add pwrap_write32 for writing | ||||
|  in 32-bit mode | ||||
| 
 | ||||
| Some regulators such as MediaTek MT6380 also has to be written in | ||||
| 32-bit mode. So the patch adds pwrap_write32, rename old pwrap_write | ||||
| into pwrap_write16 and one additional function pointer is introduced | ||||
| for increasing flexibility allowing the determination which mode is | ||||
| used by the pwrap slave detection through device tree. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 70 +++++++++++++++++++++++++++--------- | ||||
|  1 file changed, 54 insertions(+), 16 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -507,6 +507,7 @@ struct pwrap_slv_type {
 | ||||
|  	 * which type is used by the detection through device tree. | ||||
|  	 */ | ||||
|  	int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata); | ||||
| +	int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata);
 | ||||
|  }; | ||||
|   | ||||
|  struct pmic_wrapper { | ||||
| @@ -601,22 +602,6 @@ static int pwrap_wait_for_state(struct p
 | ||||
|  	} while (1); | ||||
|  } | ||||
|   | ||||
| -static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
 | ||||
| -{
 | ||||
| -	int ret;
 | ||||
| -
 | ||||
| -	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
 | ||||
| -	if (ret) {
 | ||||
| -		pwrap_leave_fsm_vldclr(wrp);
 | ||||
| -		return ret;
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata,
 | ||||
| -			PWRAP_WACS2_CMD);
 | ||||
| -
 | ||||
| -	return 0;
 | ||||
| -}
 | ||||
| -
 | ||||
|  static int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) | ||||
|  { | ||||
|  	int ret; | ||||
| @@ -673,6 +658,56 @@ static int pwrap_read(struct pmic_wrappe
 | ||||
|  	return wrp->slave->pwrap_read(wrp, adr, rdata); | ||||
|  } | ||||
|   | ||||
| +static int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
 | ||||
| +{
 | ||||
| +	int ret;
 | ||||
| +
 | ||||
| +	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
 | ||||
| +	if (ret) {
 | ||||
| +		pwrap_leave_fsm_vldclr(wrp);
 | ||||
| +		return ret;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata,
 | ||||
| +		     PWRAP_WACS2_CMD);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
 | ||||
| +{
 | ||||
| +	int ret, msb, rdata;
 | ||||
| +
 | ||||
| +	for (msb = 0; msb < 2; msb++) {
 | ||||
| +		ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
 | ||||
| +		if (ret) {
 | ||||
| +			pwrap_leave_fsm_vldclr(wrp);
 | ||||
| +			return ret;
 | ||||
| +		}
 | ||||
| +
 | ||||
| +		pwrap_writel(wrp, (1 << 31) | (msb << 30) | (adr << 16) |
 | ||||
| +			     ((wdata >> (msb * 16)) & 0xffff),
 | ||||
| +			     PWRAP_WACS2_CMD);
 | ||||
| +
 | ||||
| +		/*
 | ||||
| +		 * The pwrap_read operation is the requirement of hardware used
 | ||||
| +		 * for the synchronization between two successive 16-bit
 | ||||
| +		 * pwrap_writel operations composing one 32-bit bus writing.
 | ||||
| +		 * Otherwise, we'll find the result fails on the lower 16-bit
 | ||||
| +		 * pwrap writing.
 | ||||
| +		 */
 | ||||
| +		if (!msb)
 | ||||
| +			pwrap_read(wrp, adr, &rdata);
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
 | ||||
| +{
 | ||||
| +	return wrp->slave->pwrap_write(wrp, adr, wdata);
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int pwrap_regmap_read(void *context, u32 adr, u32 *rdata) | ||||
|  { | ||||
|  	return pwrap_read(context, adr, rdata); | ||||
| @@ -1082,18 +1117,21 @@ static const struct pwrap_slv_type pmic_
 | ||||
|  	.dew_regs = mt6323_regs, | ||||
|  	.type = PMIC_MT6323, | ||||
|  	.pwrap_read = pwrap_read16, | ||||
| +	.pwrap_write = pwrap_write16,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct pwrap_slv_type pmic_mt6380 = { | ||||
|  	.dew_regs = NULL, | ||||
|  	.type = PMIC_MT6380, | ||||
|  	.pwrap_read = pwrap_read32, | ||||
| +	.pwrap_write = pwrap_write32,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct pwrap_slv_type pmic_mt6397 = { | ||||
|  	.dew_regs = mt6397_regs, | ||||
|  	.type = PMIC_MT6397, | ||||
|  	.pwrap_read = pwrap_read16, | ||||
| +	.pwrap_write = pwrap_write16,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id of_slave_match_tbl[] = { | ||||
|  | @ -0,0 +1,227 @@ | |||
| From 16bebe4ad52083316907fb7149c797cd331f5948 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:45 +0800 | ||||
| Subject: [PATCH 119/224] soc: mediatek: pwrap: refactor pwrap_init for the | ||||
|  various PMIC types | ||||
| 
 | ||||
| pwrap initialization is highly associated with the base SoC and the | ||||
| target PMICs, so slight refactorization is made here for allowing | ||||
| pwrap_init to run on those PMICs with different capability from the | ||||
| previous MediaTek PMICs and the determination for the enablement of the | ||||
| pwrap capability depending on PMIC type. Apart from this, the patch | ||||
| makes the driver more extensible especially when more PMICs join into | ||||
| the pwrap driver. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 130 ++++++++++++++++++++++++----------- | ||||
|  1 file changed, 90 insertions(+), 40 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -70,6 +70,12 @@
 | ||||
|  					  PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \ | ||||
|  					  PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE) | ||||
|   | ||||
| +/* Group of bits used for shown slave capability */
 | ||||
| +#define PWRAP_SLV_CAP_SPI	BIT(0)
 | ||||
| +#define PWRAP_SLV_CAP_DUALIO	BIT(1)
 | ||||
| +#define PWRAP_SLV_CAP_SECURITY	BIT(2)
 | ||||
| +#define HAS_CAP(_c, _x)	(((_c) & (_x)) == (_x))
 | ||||
| +
 | ||||
|  /* defines for slave device wrapper registers */ | ||||
|  enum dew_regs { | ||||
|  	PWRAP_DEW_BASE, | ||||
| @@ -501,6 +507,8 @@ struct pmic_wrapper;
 | ||||
|  struct pwrap_slv_type { | ||||
|  	const u32 *dew_regs; | ||||
|  	enum pmic_type type; | ||||
| +	/* Flags indicating the capability for the target slave */
 | ||||
| +	u32 caps;
 | ||||
|  	/* | ||||
|  	 * pwrap operations are highly associated with the PMIC types, | ||||
|  	 * so the pointers added increases flexibility allowing determination | ||||
| @@ -787,6 +795,37 @@ static int pwrap_init_sidly(struct pmic_
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
 | ||||
| +{
 | ||||
| +	int ret;
 | ||||
| +	u32 rdata;
 | ||||
| +
 | ||||
| +	/* Enable dual IO mode */
 | ||||
| +	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
 | ||||
| +
 | ||||
| +	/* Check IDLE & INIT_DONE in advance */
 | ||||
| +	ret = pwrap_wait_for_state(wrp,
 | ||||
| +				   pwrap_is_fsm_idle_and_sync_idle);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
 | ||||
| +		return ret;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	pwrap_writel(wrp, 1, PWRAP_DIO_EN);
 | ||||
| +
 | ||||
| +	/* Read Test */
 | ||||
| +	pwrap_read(wrp,
 | ||||
| +		   wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata);
 | ||||
| +	if (rdata != PWRAP_DEW_READ_TEST_VAL) {
 | ||||
| +		dev_err(wrp->dev,
 | ||||
| +			"Read failed on DIO mode: 0x%04x!=0x%04x\n",
 | ||||
| +			PWRAP_DEW_READ_TEST_VAL, rdata);
 | ||||
| +		return -EFAULT;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp) | ||||
|  { | ||||
|  	pwrap_writel(wrp, 0x4, PWRAP_CSHEXT); | ||||
| @@ -935,6 +974,30 @@ static int pwrap_init_cipher(struct pmic
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int pwrap_init_security(struct pmic_wrapper *wrp)
 | ||||
| +{
 | ||||
| +	int ret;
 | ||||
| +
 | ||||
| +	/* Enable encryption */
 | ||||
| +	ret = pwrap_init_cipher(wrp);
 | ||||
| +	if (ret)
 | ||||
| +		return ret;
 | ||||
| +
 | ||||
| +	/* Signature checking - using CRC */
 | ||||
| +	if (pwrap_write(wrp,
 | ||||
| +			wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1))
 | ||||
| +		return -EFAULT;
 | ||||
| +
 | ||||
| +	pwrap_writel(wrp, 0x1, PWRAP_CRC_EN);
 | ||||
| +	pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE);
 | ||||
| +	pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL],
 | ||||
| +		     PWRAP_SIG_ADR);
 | ||||
| +	pwrap_writel(wrp,
 | ||||
| +		     wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp) | ||||
|  { | ||||
|  	/* enable pwrap events and pwrap bridge in AP side */ | ||||
| @@ -995,7 +1058,6 @@ static int pwrap_mt2701_init_soc_specifi
 | ||||
|  static int pwrap_init(struct pmic_wrapper *wrp) | ||||
|  { | ||||
|  	int ret; | ||||
| -	u32 rdata;
 | ||||
|   | ||||
|  	reset_control_reset(wrp->rstc); | ||||
|  	if (wrp->rstc_bridge) | ||||
| @@ -1007,10 +1069,12 @@ static int pwrap_init(struct pmic_wrappe
 | ||||
|  		pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD); | ||||
|  	} | ||||
|   | ||||
| -	/* Reset SPI slave */
 | ||||
| -	ret = pwrap_reset_spislave(wrp);
 | ||||
| -	if (ret)
 | ||||
| -		return ret;
 | ||||
| +	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
 | ||||
| +		/* Reset SPI slave */
 | ||||
| +		ret = pwrap_reset_spislave(wrp);
 | ||||
| +		if (ret)
 | ||||
| +			return ret;
 | ||||
| +	}
 | ||||
|   | ||||
|  	pwrap_writel(wrp, 1, PWRAP_WRAP_EN); | ||||
|   | ||||
| @@ -1022,45 +1086,26 @@ static int pwrap_init(struct pmic_wrappe
 | ||||
|  	if (ret) | ||||
|  		return ret; | ||||
|   | ||||
| -	/* Setup serial input delay */
 | ||||
| -	ret = pwrap_init_sidly(wrp);
 | ||||
| -	if (ret)
 | ||||
| -		return ret;
 | ||||
| -
 | ||||
| -	/* Enable dual IO mode */
 | ||||
| -	pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
 | ||||
| -
 | ||||
| -	/* Check IDLE & INIT_DONE in advance */
 | ||||
| -	ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle_and_sync_idle);
 | ||||
| -	if (ret) {
 | ||||
| -		dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret);
 | ||||
| -		return ret;
 | ||||
| +	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) {
 | ||||
| +		/* Setup serial input delay */
 | ||||
| +		ret = pwrap_init_sidly(wrp);
 | ||||
| +		if (ret)
 | ||||
| +			return ret;
 | ||||
|  	} | ||||
|   | ||||
| -	pwrap_writel(wrp, 1, PWRAP_DIO_EN);
 | ||||
| -
 | ||||
| -	/* Read Test */
 | ||||
| -	pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata);
 | ||||
| -	if (rdata != PWRAP_DEW_READ_TEST_VAL) {
 | ||||
| -		dev_err(wrp->dev, "Read test failed after switch to DIO mode: 0x%04x != 0x%04x\n",
 | ||||
| -				PWRAP_DEW_READ_TEST_VAL, rdata);
 | ||||
| -		return -EFAULT;
 | ||||
| +	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_DUALIO)) {
 | ||||
| +		/* Enable dual I/O mode */
 | ||||
| +		ret = pwrap_init_dual_io(wrp);
 | ||||
| +		if (ret)
 | ||||
| +			return ret;
 | ||||
|  	} | ||||
|   | ||||
| -	/* Enable encryption */
 | ||||
| -	ret = pwrap_init_cipher(wrp);
 | ||||
| -	if (ret)
 | ||||
| -		return ret;
 | ||||
| -
 | ||||
| -	/* Signature checking - using CRC */
 | ||||
| -	if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1))
 | ||||
| -		return -EFAULT;
 | ||||
| -
 | ||||
| -	pwrap_writel(wrp, 0x1, PWRAP_CRC_EN);
 | ||||
| -	pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE);
 | ||||
| -	pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL],
 | ||||
| -		     PWRAP_SIG_ADR);
 | ||||
| -	pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
 | ||||
| +	if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SECURITY)) {
 | ||||
| +		/* Enable security on bus */
 | ||||
| +		ret = pwrap_init_security(wrp);
 | ||||
| +		if (ret)
 | ||||
| +			return ret;
 | ||||
| +	}
 | ||||
|   | ||||
|  	if (wrp->master->type == PWRAP_MT8135) | ||||
|  		pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); | ||||
| @@ -1116,6 +1161,8 @@ static const struct regmap_config pwrap_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6323 = { | ||||
|  	.dew_regs = mt6323_regs, | ||||
|  	.type = PMIC_MT6323, | ||||
| +	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
 | ||||
| +		PWRAP_SLV_CAP_SECURITY,
 | ||||
|  	.pwrap_read = pwrap_read16, | ||||
|  	.pwrap_write = pwrap_write16, | ||||
|  }; | ||||
| @@ -1123,6 +1170,7 @@ static const struct pwrap_slv_type pmic_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6380 = { | ||||
|  	.dew_regs = NULL, | ||||
|  	.type = PMIC_MT6380, | ||||
| +	.caps = 0,
 | ||||
|  	.pwrap_read = pwrap_read32, | ||||
|  	.pwrap_write = pwrap_write32, | ||||
|  }; | ||||
| @@ -1130,6 +1178,8 @@ static const struct pwrap_slv_type pmic_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6397 = { | ||||
|  	.dew_regs = mt6397_regs, | ||||
|  	.type = PMIC_MT6397, | ||||
| +	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
 | ||||
| +		PWRAP_SLV_CAP_SECURITY,
 | ||||
|  	.pwrap_read = pwrap_read16, | ||||
|  	.pwrap_write = pwrap_write16, | ||||
|  }; | ||||
|  | @ -0,0 +1,98 @@ | |||
| From 81c54afc5bc918ea3ed65cc356236b302b1f21ca Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:46 +0800 | ||||
| Subject: [PATCH 120/224] soc: mediatek: pwrap: add MediaTek MT6380 as one | ||||
|  slave of pwrap | ||||
| 
 | ||||
| Add MediaTek MT6380 regulator becoming one of PMIC wrapper slave | ||||
| and also add extra new regmap_config of 32-bit mode for MT6380 | ||||
| since old regmap_config of 16-bit mode can't be fit into the need. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 24 +++++++++++++++++++++--- | ||||
|  1 file changed, 21 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -507,6 +507,7 @@ struct pmic_wrapper;
 | ||||
|  struct pwrap_slv_type { | ||||
|  	const u32 *dew_regs; | ||||
|  	enum pmic_type type; | ||||
| +	const struct regmap_config *regmap;
 | ||||
|  	/* Flags indicating the capability for the target slave */ | ||||
|  	u32 caps; | ||||
|  	/* | ||||
| @@ -1149,7 +1150,7 @@ static irqreturn_t pwrap_interrupt(int i
 | ||||
|  	return IRQ_HANDLED; | ||||
|  } | ||||
|   | ||||
| -static const struct regmap_config pwrap_regmap_config = {
 | ||||
| +static const struct regmap_config pwrap_regmap_config16 = {
 | ||||
|  	.reg_bits = 16, | ||||
|  	.val_bits = 16, | ||||
|  	.reg_stride = 2, | ||||
| @@ -1158,9 +1159,19 @@ static const struct regmap_config pwrap_
 | ||||
|  	.max_register = 0xffff, | ||||
|  }; | ||||
|   | ||||
| +static const struct regmap_config pwrap_regmap_config32 = {
 | ||||
| +	.reg_bits = 32,
 | ||||
| +	.val_bits = 32,
 | ||||
| +	.reg_stride = 4,
 | ||||
| +	.reg_read = pwrap_regmap_read,
 | ||||
| +	.reg_write = pwrap_regmap_write,
 | ||||
| +	.max_register = 0xffff,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static const struct pwrap_slv_type pmic_mt6323 = { | ||||
|  	.dew_regs = mt6323_regs, | ||||
|  	.type = PMIC_MT6323, | ||||
| +	.regmap = &pwrap_regmap_config16,
 | ||||
|  	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO | | ||||
|  		PWRAP_SLV_CAP_SECURITY, | ||||
|  	.pwrap_read = pwrap_read16, | ||||
| @@ -1170,6 +1181,7 @@ static const struct pwrap_slv_type pmic_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6380 = { | ||||
|  	.dew_regs = NULL, | ||||
|  	.type = PMIC_MT6380, | ||||
| +	.regmap = &pwrap_regmap_config32,
 | ||||
|  	.caps = 0, | ||||
|  	.pwrap_read = pwrap_read32, | ||||
|  	.pwrap_write = pwrap_write32, | ||||
| @@ -1178,6 +1190,7 @@ static const struct pwrap_slv_type pmic_
 | ||||
|  static const struct pwrap_slv_type pmic_mt6397 = { | ||||
|  	.dew_regs = mt6397_regs, | ||||
|  	.type = PMIC_MT6397, | ||||
| +	.regmap = &pwrap_regmap_config16,
 | ||||
|  	.caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO | | ||||
|  		PWRAP_SLV_CAP_SECURITY, | ||||
|  	.pwrap_read = pwrap_read16, | ||||
| @@ -1189,9 +1202,14 @@ static const struct of_device_id of_slav
 | ||||
|  		.compatible = "mediatek,mt6323", | ||||
|  		.data = &pmic_mt6323, | ||||
|  	}, { | ||||
| +		/* The MT6380 PMIC only implements a regulator, so we bind it
 | ||||
| +		 * directly instead of using a MFD.
 | ||||
| +		 */
 | ||||
| +		.compatible = "mediatek,mt6380-regulator",
 | ||||
| +		.data = &pmic_mt6380,
 | ||||
| +	}, {
 | ||||
|  		.compatible = "mediatek,mt6397", | ||||
|  		.data = &pmic_mt6397, | ||||
| -	}, {
 | ||||
|  		/* sentinel */ | ||||
|  	} | ||||
|  }; | ||||
| @@ -1372,7 +1390,7 @@ static int pwrap_probe(struct platform_d
 | ||||
|  	if (ret) | ||||
|  		goto err_out2; | ||||
|   | ||||
| -	wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, &pwrap_regmap_config);
 | ||||
| +	wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regmap);
 | ||||
|  	if (IS_ERR(wrp->regmap)) { | ||||
|  		ret = PTR_ERR(wrp->regmap); | ||||
|  		goto err_out2; | ||||
|  | @ -0,0 +1,121 @@ | |||
| From 442c890727e0f585154662b0908fbe3a7986052a Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:47 +0800 | ||||
| Subject: [PATCH 121/224] soc: mediatek: pwrap: add common way for setup CS | ||||
|  timing extenstion | ||||
| 
 | ||||
| Multiple platforms would always use their own way handling CS timing | ||||
| extension on the bus which leads to a little bit code duplication. | ||||
| Therefore, the patch groups the similar logic to handle CS timing | ||||
| extension into the common function which allows the following SoCs | ||||
| have more reusability for configing CS timing. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 59 ++++++++++++++++++++++-------------- | ||||
|  1 file changed, 37 insertions(+), 22 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -827,23 +827,44 @@ static int pwrap_init_dual_io(struct pmi
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| -static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp)
 | ||||
| -{
 | ||||
| -	pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
 | ||||
| -	pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
 | ||||
| -	pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
 | ||||
| -	pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START);
 | ||||
| -	pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END);
 | ||||
| -
 | ||||
| -	return 0;
 | ||||
| +/*
 | ||||
| + * pwrap_init_chip_select_ext is used to configure CS extension time for each
 | ||||
| + * phase during data transactions on the pwrap bus.
 | ||||
| + */
 | ||||
| +static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
 | ||||
| +				       u8 hext_read, u8 lext_start,
 | ||||
| +				       u8 lext_end)
 | ||||
| +{
 | ||||
| +	/*
 | ||||
| +	 * After finishing a write and read transaction, extends CS high time
 | ||||
| +	 * to be at least xT of BUS CLK as hext_write and hext_read specifies
 | ||||
| +	 * respectively.
 | ||||
| +	 */
 | ||||
| +	pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE);
 | ||||
| +	pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ);
 | ||||
| +
 | ||||
| +	/*
 | ||||
| +	 * Extends CS low time after CSL and before CSH command to be at
 | ||||
| +	 * least xT of BUS CLK as lext_start and lext_end specifies
 | ||||
| +	 * respectively.
 | ||||
| +	 */
 | ||||
| +	pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START);
 | ||||
| +	pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END);
 | ||||
|  } | ||||
|   | ||||
| -static int pwrap_mt8173_init_reg_clock(struct pmic_wrapper *wrp)
 | ||||
| +static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
 | ||||
|  { | ||||
| -	pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
 | ||||
| -	pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
 | ||||
| -	pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
 | ||||
| -	pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
 | ||||
| +	switch (wrp->master->type) {
 | ||||
| +	case PWRAP_MT8173:
 | ||||
| +		pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2);
 | ||||
| +		break;
 | ||||
| +	case PWRAP_MT8135:
 | ||||
| +		pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
 | ||||
| +		pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0);
 | ||||
| +		break;
 | ||||
| +	default:
 | ||||
| +		break;
 | ||||
| +	}
 | ||||
|   | ||||
|  	return 0; | ||||
|  } | ||||
| @@ -853,20 +874,14 @@ static int pwrap_mt2701_init_reg_clock(s
 | ||||
|  	switch (wrp->slave->type) { | ||||
|  	case PMIC_MT6397: | ||||
|  		pwrap_writel(wrp, 0xc, PWRAP_RDDMY); | ||||
| -		pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_WRITE);
 | ||||
| -		pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ);
 | ||||
| -		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
 | ||||
| -		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
 | ||||
| +		pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2);
 | ||||
|  		break; | ||||
|   | ||||
|  	case PMIC_MT6323: | ||||
|  		pwrap_writel(wrp, 0x8, PWRAP_RDDMY); | ||||
|  		pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], | ||||
|  			    0x8); | ||||
| -		pwrap_writel(wrp, 0x5, PWRAP_CSHEXT_WRITE);
 | ||||
| -		pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ);
 | ||||
| -		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
 | ||||
| -		pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
 | ||||
| +		pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2);
 | ||||
|  		break; | ||||
|  	default: | ||||
|  		break; | ||||
| @@ -1235,7 +1250,7 @@ static const struct pmic_wrapper_type pw
 | ||||
|  	.spi_w = PWRAP_MAN_CMD_SPI_WRITE, | ||||
|  	.wdt_src = PWRAP_WDT_SRC_MASK_ALL, | ||||
|  	.has_bridge = 1, | ||||
| -	.init_reg_clock = pwrap_mt8135_init_reg_clock,
 | ||||
| +	.init_reg_clock = pwrap_common_init_reg_clock,
 | ||||
|  	.init_soc_specific = pwrap_mt8135_init_soc_specific, | ||||
|  }; | ||||
|   | ||||
| @@ -1247,7 +1262,7 @@ static const struct pmic_wrapper_type pw
 | ||||
|  	.spi_w = PWRAP_MAN_CMD_SPI_WRITE, | ||||
|  	.wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD, | ||||
|  	.has_bridge = 0, | ||||
| -	.init_reg_clock = pwrap_mt8173_init_reg_clock,
 | ||||
| +	.init_reg_clock = pwrap_common_init_reg_clock,
 | ||||
|  	.init_soc_specific = pwrap_mt8173_init_soc_specific, | ||||
|  }; | ||||
|   | ||||
|  | @ -0,0 +1,237 @@ | |||
| From 87996dabef0d83bbd2ed5264b83b01224bc42968 Mon Sep 17 00:00:00 2001 | ||||
| From: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Date: Wed, 18 Oct 2017 16:28:48 +0800 | ||||
| Subject: [PATCH 122/224] soc: mediatek: pwrap: add support for MT7622 SoC | ||||
| 
 | ||||
| Add the registers, callbacks and data structures required to make the | ||||
| PMIC wrapper work on MT7622. | ||||
| 
 | ||||
| Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com> | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/mtk-pmic-wrap.c | 170 +++++++++++++++++++++++++++++++++++ | ||||
|  1 file changed, 170 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | ||||
| @@ -214,6 +214,36 @@ enum pwrap_regs {
 | ||||
|  	PWRAP_ADC_RDATA_ADDR1, | ||||
|  	PWRAP_ADC_RDATA_ADDR2, | ||||
|   | ||||
| +	/* MT7622 only regs */
 | ||||
| +	PWRAP_EINT_STA0_ADR,
 | ||||
| +	PWRAP_EINT_STA1_ADR,
 | ||||
| +	PWRAP_STA,
 | ||||
| +	PWRAP_CLR,
 | ||||
| +	PWRAP_DVFS_ADR8,
 | ||||
| +	PWRAP_DVFS_WDATA8,
 | ||||
| +	PWRAP_DVFS_ADR9,
 | ||||
| +	PWRAP_DVFS_WDATA9,
 | ||||
| +	PWRAP_DVFS_ADR10,
 | ||||
| +	PWRAP_DVFS_WDATA10,
 | ||||
| +	PWRAP_DVFS_ADR11,
 | ||||
| +	PWRAP_DVFS_WDATA11,
 | ||||
| +	PWRAP_DVFS_ADR12,
 | ||||
| +	PWRAP_DVFS_WDATA12,
 | ||||
| +	PWRAP_DVFS_ADR13,
 | ||||
| +	PWRAP_DVFS_WDATA13,
 | ||||
| +	PWRAP_DVFS_ADR14,
 | ||||
| +	PWRAP_DVFS_WDATA14,
 | ||||
| +	PWRAP_DVFS_ADR15,
 | ||||
| +	PWRAP_DVFS_WDATA15,
 | ||||
| +	PWRAP_EXT_CK,
 | ||||
| +	PWRAP_ADC_RDATA_ADDR,
 | ||||
| +	PWRAP_GPS_STA,
 | ||||
| +	PWRAP_SW_RST,
 | ||||
| +	PWRAP_DVFS_STEP_CTRL0,
 | ||||
| +	PWRAP_DVFS_STEP_CTRL1,
 | ||||
| +	PWRAP_DVFS_STEP_CTRL2,
 | ||||
| +	PWRAP_SPI2_CTRL,
 | ||||
| +
 | ||||
|  	/* MT8135 only regs */ | ||||
|  	PWRAP_CSHEXT, | ||||
|  	PWRAP_EVENT_IN_EN, | ||||
| @@ -336,6 +366,118 @@ static int mt2701_regs[] = {
 | ||||
|  	[PWRAP_ADC_RDATA_ADDR2] =	0x154, | ||||
|  }; | ||||
|   | ||||
| +static int mt7622_regs[] = {
 | ||||
| +	[PWRAP_MUX_SEL] =		0x0,
 | ||||
| +	[PWRAP_WRAP_EN] =		0x4,
 | ||||
| +	[PWRAP_DIO_EN] =		0x8,
 | ||||
| +	[PWRAP_SIDLY] =			0xC,
 | ||||
| +	[PWRAP_RDDMY] =			0x10,
 | ||||
| +	[PWRAP_SI_CK_CON] =		0x14,
 | ||||
| +	[PWRAP_CSHEXT_WRITE] =		0x18,
 | ||||
| +	[PWRAP_CSHEXT_READ] =		0x1C,
 | ||||
| +	[PWRAP_CSLEXT_START] =		0x20,
 | ||||
| +	[PWRAP_CSLEXT_END] =		0x24,
 | ||||
| +	[PWRAP_STAUPD_PRD] =		0x28,
 | ||||
| +	[PWRAP_STAUPD_GRPEN] =		0x2C,
 | ||||
| +	[PWRAP_EINT_STA0_ADR] =		0x30,
 | ||||
| +	[PWRAP_EINT_STA1_ADR] =		0x34,
 | ||||
| +	[PWRAP_STA] =			0x38,
 | ||||
| +	[PWRAP_CLR] =			0x3C,
 | ||||
| +	[PWRAP_STAUPD_MAN_TRIG] =	0x40,
 | ||||
| +	[PWRAP_STAUPD_STA] =		0x44,
 | ||||
| +	[PWRAP_WRAP_STA] =		0x48,
 | ||||
| +	[PWRAP_HARB_INIT] =		0x4C,
 | ||||
| +	[PWRAP_HARB_HPRIO] =		0x50,
 | ||||
| +	[PWRAP_HIPRIO_ARB_EN] =		0x54,
 | ||||
| +	[PWRAP_HARB_STA0] =		0x58,
 | ||||
| +	[PWRAP_HARB_STA1] =		0x5C,
 | ||||
| +	[PWRAP_MAN_EN] =		0x60,
 | ||||
| +	[PWRAP_MAN_CMD] =		0x64,
 | ||||
| +	[PWRAP_MAN_RDATA] =		0x68,
 | ||||
| +	[PWRAP_MAN_VLDCLR] =		0x6C,
 | ||||
| +	[PWRAP_WACS0_EN] =		0x70,
 | ||||
| +	[PWRAP_INIT_DONE0] =		0x74,
 | ||||
| +	[PWRAP_WACS0_CMD] =		0x78,
 | ||||
| +	[PWRAP_WACS0_RDATA] =		0x7C,
 | ||||
| +	[PWRAP_WACS0_VLDCLR] =		0x80,
 | ||||
| +	[PWRAP_WACS1_EN] =		0x84,
 | ||||
| +	[PWRAP_INIT_DONE1] =		0x88,
 | ||||
| +	[PWRAP_WACS1_CMD] =		0x8C,
 | ||||
| +	[PWRAP_WACS1_RDATA] =		0x90,
 | ||||
| +	[PWRAP_WACS1_VLDCLR] =		0x94,
 | ||||
| +	[PWRAP_WACS2_EN] =		0x98,
 | ||||
| +	[PWRAP_INIT_DONE2] =		0x9C,
 | ||||
| +	[PWRAP_WACS2_CMD] =		0xA0,
 | ||||
| +	[PWRAP_WACS2_RDATA] =		0xA4,
 | ||||
| +	[PWRAP_WACS2_VLDCLR] =		0xA8,
 | ||||
| +	[PWRAP_INT_EN] =		0xAC,
 | ||||
| +	[PWRAP_INT_FLG_RAW] =		0xB0,
 | ||||
| +	[PWRAP_INT_FLG] =		0xB4,
 | ||||
| +	[PWRAP_INT_CLR] =		0xB8,
 | ||||
| +	[PWRAP_SIG_ADR] =		0xBC,
 | ||||
| +	[PWRAP_SIG_MODE] =		0xC0,
 | ||||
| +	[PWRAP_SIG_VALUE] =		0xC4,
 | ||||
| +	[PWRAP_SIG_ERRVAL] =		0xC8,
 | ||||
| +	[PWRAP_CRC_EN] =		0xCC,
 | ||||
| +	[PWRAP_TIMER_EN] =		0xD0,
 | ||||
| +	[PWRAP_TIMER_STA] =		0xD4,
 | ||||
| +	[PWRAP_WDT_UNIT] =		0xD8,
 | ||||
| +	[PWRAP_WDT_SRC_EN] =		0xDC,
 | ||||
| +	[PWRAP_WDT_FLG] =		0xE0,
 | ||||
| +	[PWRAP_DEBUG_INT_SEL] =		0xE4,
 | ||||
| +	[PWRAP_DVFS_ADR0] =		0xE8,
 | ||||
| +	[PWRAP_DVFS_WDATA0] =		0xEC,
 | ||||
| +	[PWRAP_DVFS_ADR1] =		0xF0,
 | ||||
| +	[PWRAP_DVFS_WDATA1] =		0xF4,
 | ||||
| +	[PWRAP_DVFS_ADR2] =		0xF8,
 | ||||
| +	[PWRAP_DVFS_WDATA2] =		0xFC,
 | ||||
| +	[PWRAP_DVFS_ADR3] =		0x100,
 | ||||
| +	[PWRAP_DVFS_WDATA3] =		0x104,
 | ||||
| +	[PWRAP_DVFS_ADR4] =		0x108,
 | ||||
| +	[PWRAP_DVFS_WDATA4] =		0x10C,
 | ||||
| +	[PWRAP_DVFS_ADR5] =		0x110,
 | ||||
| +	[PWRAP_DVFS_WDATA5] =		0x114,
 | ||||
| +	[PWRAP_DVFS_ADR6] =		0x118,
 | ||||
| +	[PWRAP_DVFS_WDATA6] =		0x11C,
 | ||||
| +	[PWRAP_DVFS_ADR7] =		0x120,
 | ||||
| +	[PWRAP_DVFS_WDATA7] =		0x124,
 | ||||
| +	[PWRAP_DVFS_ADR8] =		0x128,
 | ||||
| +	[PWRAP_DVFS_WDATA8] =		0x12C,
 | ||||
| +	[PWRAP_DVFS_ADR9] =		0x130,
 | ||||
| +	[PWRAP_DVFS_WDATA9] =		0x134,
 | ||||
| +	[PWRAP_DVFS_ADR10] =		0x138,
 | ||||
| +	[PWRAP_DVFS_WDATA10] =		0x13C,
 | ||||
| +	[PWRAP_DVFS_ADR11] =		0x140,
 | ||||
| +	[PWRAP_DVFS_WDATA11] =		0x144,
 | ||||
| +	[PWRAP_DVFS_ADR12] =		0x148,
 | ||||
| +	[PWRAP_DVFS_WDATA12] =		0x14C,
 | ||||
| +	[PWRAP_DVFS_ADR13] =		0x150,
 | ||||
| +	[PWRAP_DVFS_WDATA13] =		0x154,
 | ||||
| +	[PWRAP_DVFS_ADR14] =		0x158,
 | ||||
| +	[PWRAP_DVFS_WDATA14] =		0x15C,
 | ||||
| +	[PWRAP_DVFS_ADR15] =		0x160,
 | ||||
| +	[PWRAP_DVFS_WDATA15] =		0x164,
 | ||||
| +	[PWRAP_SPMINF_STA] =		0x168,
 | ||||
| +	[PWRAP_CIPHER_KEY_SEL] =	0x16C,
 | ||||
| +	[PWRAP_CIPHER_IV_SEL] =		0x170,
 | ||||
| +	[PWRAP_CIPHER_EN] =		0x174,
 | ||||
| +	[PWRAP_CIPHER_RDY] =		0x178,
 | ||||
| +	[PWRAP_CIPHER_MODE] =		0x17C,
 | ||||
| +	[PWRAP_CIPHER_SWRST] =		0x180,
 | ||||
| +	[PWRAP_DCM_EN] =		0x184,
 | ||||
| +	[PWRAP_DCM_DBC_PRD] =		0x188,
 | ||||
| +	[PWRAP_EXT_CK] =		0x18C,
 | ||||
| +	[PWRAP_ADC_CMD_ADDR] =		0x190,
 | ||||
| +	[PWRAP_PWRAP_ADC_CMD] =		0x194,
 | ||||
| +	[PWRAP_ADC_RDATA_ADDR] =	0x198,
 | ||||
| +	[PWRAP_GPS_STA] =		0x19C,
 | ||||
| +	[PWRAP_SW_RST] =		0x1A0,
 | ||||
| +	[PWRAP_DVFS_STEP_CTRL0] =	0x238,
 | ||||
| +	[PWRAP_DVFS_STEP_CTRL1] =	0x23C,
 | ||||
| +	[PWRAP_DVFS_STEP_CTRL2] =	0x240,
 | ||||
| +	[PWRAP_SPI2_CTRL] =		0x244,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static int mt8173_regs[] = { | ||||
|  	[PWRAP_MUX_SEL] =		0x0, | ||||
|  	[PWRAP_WRAP_EN] =		0x4, | ||||
| @@ -499,6 +641,7 @@ enum pmic_type {
 | ||||
|   | ||||
|  enum pwrap_type { | ||||
|  	PWRAP_MT2701, | ||||
| +	PWRAP_MT7622,
 | ||||
|  	PWRAP_MT8135, | ||||
|  	PWRAP_MT8173, | ||||
|  }; | ||||
| @@ -927,6 +1070,9 @@ static int pwrap_init_cipher(struct pmic
 | ||||
|  	case PWRAP_MT8173: | ||||
|  		pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); | ||||
|  		break; | ||||
| +	case PWRAP_MT7622:
 | ||||
| +		pwrap_writel(wrp, 0, PWRAP_CIPHER_EN);
 | ||||
| +		break;
 | ||||
|  	} | ||||
|   | ||||
|  	/* Config cipher mode @PMIC */ | ||||
| @@ -1071,6 +1217,15 @@ static int pwrap_mt2701_init_soc_specifi
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp)
 | ||||
| +{
 | ||||
| +	pwrap_writel(wrp, 0, PWRAP_STAUPD_PRD);
 | ||||
| +	/* enable 2wire SPI master */
 | ||||
| +	pwrap_writel(wrp, 0x8000000, PWRAP_SPI2_CTRL);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int pwrap_init(struct pmic_wrapper *wrp) | ||||
|  { | ||||
|  	int ret; | ||||
| @@ -1242,6 +1397,18 @@ static const struct pmic_wrapper_type pw
 | ||||
|  	.init_soc_specific = pwrap_mt2701_init_soc_specific, | ||||
|  }; | ||||
|   | ||||
| +static const struct pmic_wrapper_type pwrap_mt7622 = {
 | ||||
| +	.regs = mt7622_regs,
 | ||||
| +	.type = PWRAP_MT7622,
 | ||||
| +	.arb_en_all = 0xff,
 | ||||
| +	.int_en_all = ~(u32)BIT(31),
 | ||||
| +	.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
 | ||||
| +	.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
 | ||||
| +	.has_bridge = 0,
 | ||||
| +	.init_reg_clock = pwrap_common_init_reg_clock,
 | ||||
| +	.init_soc_specific = pwrap_mt7622_init_soc_specific,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static const struct pmic_wrapper_type pwrap_mt8135 = { | ||||
|  	.regs = mt8135_regs, | ||||
|  	.type = PWRAP_MT8135, | ||||
| @@ -1271,6 +1438,9 @@ static const struct of_device_id of_pwra
 | ||||
|  		.compatible = "mediatek,mt2701-pwrap", | ||||
|  		.data = &pwrap_mt2701, | ||||
|  	}, { | ||||
| +		.compatible = "mediatek,mt7622-pwrap",
 | ||||
| +		.data = &pwrap_mt7622,
 | ||||
| +	}, {
 | ||||
|  		.compatible = "mediatek,mt8135-pwrap", | ||||
|  		.data = &pwrap_mt8135, | ||||
|  	}, { | ||||
|  | @ -0,0 +1,57 @@ | |||
| From 21501b17e017cb10f1a64a73e62e3e2e91a52efa Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Thu, 5 Oct 2017 11:17:49 +0800 | ||||
| Subject: [PATCH 123/224] soc: mediatek: place Kconfig for all SoC drivers | ||||
|  under menu | ||||
| 
 | ||||
| Add cleanup for placing all Kconfig for all MediaTek SoC drivers under | ||||
| the independent menu as other SoCs vendor usually did. Since the menu | ||||
| would be shown depending on "ARCH_MEDIATEK || COMPILE_TEST" selected and | ||||
| MTK_PMIC_WRAP is still safe compiling with the case of "COMPILE_TEST" | ||||
| only, the superfluous dependency for those items under the menu also is | ||||
| also being removed for the sake of simplicity. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Reviewed-by: Jean Delvare <jdelvare@suse.de> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  drivers/soc/mediatek/Kconfig | 8 +++++--- | ||||
|  1 file changed, 5 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/soc/mediatek/Kconfig
 | ||||
| +++ b/drivers/soc/mediatek/Kconfig
 | ||||
| @@ -1,9 +1,11 @@
 | ||||
|  # | ||||
|  # MediaTek SoC drivers | ||||
|  # | ||||
| +menu "MediaTek SoC drivers"
 | ||||
| +	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
| +
 | ||||
|  config MTK_INFRACFG | ||||
|  	bool "MediaTek INFRACFG Support" | ||||
| -	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
|  	select REGMAP | ||||
|  	help | ||||
|  	  Say yes here to add support for the MediaTek INFRACFG controller. The | ||||
| @@ -12,7 +14,6 @@ config MTK_INFRACFG
 | ||||
|   | ||||
|  config MTK_PMIC_WRAP | ||||
|  	tristate "MediaTek PMIC Wrapper Support" | ||||
| -	depends on ARCH_MEDIATEK
 | ||||
|  	depends on RESET_CONTROLLER | ||||
|  	select REGMAP | ||||
|  	help | ||||
| @@ -22,7 +23,6 @@ config MTK_PMIC_WRAP
 | ||||
|   | ||||
|  config MTK_SCPSYS | ||||
|  	bool "MediaTek SCPSYS Support" | ||||
| -	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
|  	default ARCH_MEDIATEK | ||||
|  	select REGMAP | ||||
|  	select MTK_INFRACFG | ||||
| @@ -30,3 +30,5 @@ config MTK_SCPSYS
 | ||||
|  	help | ||||
|  	  Say yes here to add support for the MediaTek SCPSYS power domain | ||||
|  	  driver. | ||||
| +
 | ||||
| +endmenu
 | ||||
|  | @ -0,0 +1,34 @@ | |||
| From f9bea440dd8dbf1eda8644e4b1d76503053f17b6 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Thu, 19 Oct 2017 17:52:54 +0800 | ||||
| Subject: [PATCH 124/224] arm64: mediatek: cleanup message for platform | ||||
|  selection | ||||
| 
 | ||||
| The latest kernel tree already can support more MediaTek platforms such as | ||||
| MT2712 and MT7622, so additional descriptions for those platforms are added | ||||
| and certain cleanups are also being made here. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  arch/arm64/Kconfig.platforms | 5 +++-- | ||||
|  1 file changed, 3 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/arch/arm64/Kconfig.platforms
 | ||||
| +++ b/arch/arm64/Kconfig.platforms
 | ||||
| @@ -91,12 +91,13 @@ config ARCH_HISI
 | ||||
|  	  This enables support for Hisilicon ARMv8 SoC family | ||||
|   | ||||
|  config ARCH_MEDIATEK | ||||
| -	bool "Mediatek MT65xx & MT81xx ARMv8 SoC"
 | ||||
| +	bool "MediaTek SoC Family"
 | ||||
|  	select ARM_GIC | ||||
|  	select PINCTRL | ||||
|  	select MTK_TIMER | ||||
|  	help | ||||
| -	  Support for Mediatek MT65xx & MT81xx ARMv8 SoCs
 | ||||
| +	  This enables support for MediaTek MT27xx, MT65xx, MT76xx
 | ||||
| +	  & MT81xx ARMv8 SoCs
 | ||||
|   | ||||
|  config ARCH_MESON | ||||
|  	bool "Amlogic Platforms" | ||||
|  | @ -0,0 +1,86 @@ | |||
| From d42ebed1aa669c5a897ec0aa5e1ede8d9069894a Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Thu, 21 Sep 2017 18:31:49 +0800 | ||||
| Subject: [PATCH 125/224] phy: phy-mtk-tphy: add set_mode callback | ||||
| 
 | ||||
| This is used to force PHY with USB OTG function to enter a specific | ||||
| mode, and override OTG IDPIN(or IDDIG) signal. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> | ||||
| ---
 | ||||
|  drivers/phy/mediatek/phy-mtk-tphy.c | 39 +++++++++++++++++++++++++++++++++++++ | ||||
|  1 file changed, 39 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/phy/mediatek/phy-mtk-tphy.c
 | ||||
| +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
 | ||||
| @@ -96,9 +96,11 @@
 | ||||
|   | ||||
|  #define U3P_U2PHYDTM1		0x06C | ||||
|  #define P2C_RG_UART_EN			BIT(16) | ||||
| +#define P2C_FORCE_IDDIG		BIT(9)
 | ||||
|  #define P2C_RG_VBUSVALID		BIT(5) | ||||
|  #define P2C_RG_SESSEND			BIT(4) | ||||
|  #define P2C_RG_AVALID			BIT(2) | ||||
| +#define P2C_RG_IDDIG			BIT(1)
 | ||||
|   | ||||
|  #define U3P_U3_CHIP_GPIO_CTLD		0x0c | ||||
|  #define P3C_REG_IP_SW_RST		BIT(31) | ||||
| @@ -585,6 +587,31 @@ static void u2_phy_instance_exit(struct
 | ||||
|  	} | ||||
|  } | ||||
|   | ||||
| +static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
 | ||||
| +				     struct mtk_phy_instance *instance,
 | ||||
| +				     enum phy_mode mode)
 | ||||
| +{
 | ||||
| +	struct u2phy_banks *u2_banks = &instance->u2_banks;
 | ||||
| +	u32 tmp;
 | ||||
| +
 | ||||
| +	tmp = readl(u2_banks->com + U3P_U2PHYDTM1);
 | ||||
| +	switch (mode) {
 | ||||
| +	case PHY_MODE_USB_DEVICE:
 | ||||
| +		tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG;
 | ||||
| +		break;
 | ||||
| +	case PHY_MODE_USB_HOST:
 | ||||
| +		tmp |= P2C_FORCE_IDDIG;
 | ||||
| +		tmp &= ~P2C_RG_IDDIG;
 | ||||
| +		break;
 | ||||
| +	case PHY_MODE_USB_OTG:
 | ||||
| +		tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG);
 | ||||
| +		break;
 | ||||
| +	default:
 | ||||
| +		return;
 | ||||
| +	}
 | ||||
| +	writel(tmp, u2_banks->com + U3P_U2PHYDTM1);
 | ||||
| +}
 | ||||
| +
 | ||||
|  static void pcie_phy_instance_init(struct mtk_tphy *tphy, | ||||
|  	struct mtk_phy_instance *instance) | ||||
|  { | ||||
| @@ -881,6 +908,17 @@ static int mtk_phy_exit(struct phy *phy)
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode)
 | ||||
| +{
 | ||||
| +	struct mtk_phy_instance *instance = phy_get_drvdata(phy);
 | ||||
| +	struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);
 | ||||
| +
 | ||||
| +	if (instance->type == PHY_TYPE_USB2)
 | ||||
| +		u2_phy_instance_set_mode(tphy, instance, mode);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static struct phy *mtk_phy_xlate(struct device *dev, | ||||
|  					struct of_phandle_args *args) | ||||
|  { | ||||
| @@ -931,6 +969,7 @@ static const struct phy_ops mtk_tphy_ops
 | ||||
|  	.exit		= mtk_phy_exit, | ||||
|  	.power_on	= mtk_phy_power_on, | ||||
|  	.power_off	= mtk_phy_power_off, | ||||
| +	.set_mode	= mtk_phy_set_mode,
 | ||||
|  	.owner		= THIS_MODULE, | ||||
|  }; | ||||
|   | ||||
|  | @ -0,0 +1,35 @@ | |||
| From 9f617ce19c5dab429a539d411204ae220b5b8cd6 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:33 +0800 | ||||
| Subject: [PATCH 126/224] usb: xhci-mtk: use dma_set_mask_and_coherent() in | ||||
|  probe function | ||||
| 
 | ||||
| This patch uses the simpler dma_set_mask_and_coherent() instead of | ||||
| doing these as separate steps | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk.c | 7 +------ | ||||
|  1 file changed, 1 insertion(+), 6 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -606,15 +606,10 @@ static int xhci_mtk_probe(struct platfor
 | ||||
|  	} | ||||
|   | ||||
|  	/* Initialize dma_mask and coherent_dma_mask to 32-bits */ | ||||
| -	ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
 | ||||
| +	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
 | ||||
|  	if (ret) | ||||
|  		goto disable_clk; | ||||
|   | ||||
| -	if (!dev->dma_mask)
 | ||||
| -		dev->dma_mask = &dev->coherent_dma_mask;
 | ||||
| -	else
 | ||||
| -		dma_set_mask(dev, DMA_BIT_MASK(32));
 | ||||
| -
 | ||||
|  	hcd = usb_create_hcd(driver, dev, dev_name(dev)); | ||||
|  	if (!hcd) { | ||||
|  		ret = -ENOMEM; | ||||
|  | @ -0,0 +1,53 @@ | |||
| From f97aa71fe34135e7fc8da6231e61ee06f79d739d Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:34 +0800 | ||||
| Subject: [PATCH 127/224] usb: xhci-mtk: use ports count from xhci in | ||||
|  xhci_mtk_sch_init() | ||||
| 
 | ||||
| Make use of ports count from xhci but not from ippc in | ||||
| xhci_mtk_sch_init() | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk-sch.c | 3 ++- | ||||
|  drivers/usb/host/xhci-mtk.c     | 3 --- | ||||
|  2 files changed, 2 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk-sch.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk-sch.c
 | ||||
| @@ -287,12 +287,13 @@ static bool need_bw_sch(struct usb_host_
 | ||||
|   | ||||
|  int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk) | ||||
|  { | ||||
| +	struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
 | ||||
|  	struct mu3h_sch_bw_info *sch_array; | ||||
|  	int num_usb_bus; | ||||
|  	int i; | ||||
|   | ||||
|  	/* ss IN and OUT are separated */ | ||||
| -	num_usb_bus = mtk->num_u3_ports * 2 + mtk->num_u2_ports;
 | ||||
| +	num_usb_bus = xhci->num_usb3_ports * 2 + xhci->num_usb2_ports;
 | ||||
|   | ||||
|  	sch_array = kcalloc(num_usb_bus, sizeof(*sch_array), GFP_KERNEL); | ||||
|  	if (sch_array == NULL) | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -492,7 +492,6 @@ static void xhci_mtk_quirks(struct devic
 | ||||
|  /* called during probe() after chip reset completes */ | ||||
|  static int xhci_mtk_setup(struct usb_hcd *hcd) | ||||
|  { | ||||
| -	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 | ||||
|  	struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); | ||||
|  	int ret; | ||||
|   | ||||
| @@ -507,8 +506,6 @@ static int xhci_mtk_setup(struct usb_hcd
 | ||||
|  		return ret; | ||||
|   | ||||
|  	if (usb_hcd_is_primary_hcd(hcd)) { | ||||
| -		mtk->num_u3_ports = xhci->num_usb3_ports;
 | ||||
| -		mtk->num_u2_ports = xhci->num_usb2_ports;
 | ||||
|  		ret = xhci_mtk_sch_init(mtk); | ||||
|  		if (ret) | ||||
|  			return ret; | ||||
|  | @ -0,0 +1,36 @@ | |||
| From 4422c4efeed2a8b9fa745c6e529623d89c0be75e Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:35 +0800 | ||||
| Subject: [PATCH 128/224] usb: xhci-mtk: check clock stability of U3_MAC | ||||
| 
 | ||||
| This is useful to find out the root cause when the Super Speed doesn't | ||||
| work. Such as when the T-PHY is switched to PCIe or SATA, and affects | ||||
| Super Speed function, the check will fail. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk.c | 4 ++++ | ||||
|  1 file changed, 4 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -43,6 +43,7 @@
 | ||||
|   | ||||
|  /* ip_pw_sts1 register */ | ||||
|  #define STS1_IP_SLEEP_STS	BIT(30) | ||||
| +#define STS1_U3_MAC_RST	BIT(16)
 | ||||
|  #define STS1_XHCI_RST		BIT(11) | ||||
|  #define STS1_SYS125_RST	BIT(10) | ||||
|  #define STS1_REF_RST		BIT(8) | ||||
| @@ -125,6 +126,9 @@ static int xhci_mtk_host_enable(struct x
 | ||||
|  	check_val = STS1_SYSPLL_STABLE | STS1_REF_RST | | ||||
|  			STS1_SYS125_RST | STS1_XHCI_RST; | ||||
|   | ||||
| +	if (mtk->num_u3_ports)
 | ||||
| +		check_val |= STS1_U3_MAC_RST;
 | ||||
| +
 | ||||
|  	ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, | ||||
|  			  (check_val == (value & check_val)), 100, 20000); | ||||
|  	if (ret) { | ||||
|  | @ -0,0 +1,85 @@ | |||
| From 13a1b2e927893cbb046a1ec5a55ec3516873a3f6 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:36 +0800 | ||||
| Subject: [PATCH 129/224] usb: xhci-mtk: support option to disable usb3 ports | ||||
| 
 | ||||
| Add support to disable specific usb3 ports, it's useful when | ||||
| usb3 phy is shared with PCIe or SATA, because we should disable | ||||
| the corresponding usb3 port if the phy is used by PCIe or SATA. | ||||
| Sometimes it's helpful to analyse and solve problems. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk.c | 18 +++++++++++++++--- | ||||
|  drivers/usb/host/xhci-mtk.h |  1 + | ||||
|  2 files changed, 16 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -92,6 +92,7 @@ static int xhci_mtk_host_enable(struct x
 | ||||
|  { | ||||
|  	struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; | ||||
|  	u32 value, check_val; | ||||
| +	int u3_ports_disabed = 0;
 | ||||
|  	int ret; | ||||
|  	int i; | ||||
|   | ||||
| @@ -103,8 +104,13 @@ static int xhci_mtk_host_enable(struct x
 | ||||
|  	value &= ~CTRL1_IP_HOST_PDN; | ||||
|  	writel(value, &ippc->ip_pw_ctr1); | ||||
|   | ||||
| -	/* power on and enable all u3 ports */
 | ||||
| +	/* power on and enable u3 ports except skipped ones */
 | ||||
|  	for (i = 0; i < mtk->num_u3_ports; i++) { | ||||
| +		if ((0x1 << i) & mtk->u3p_dis_msk) {
 | ||||
| +			u3_ports_disabed++;
 | ||||
| +			continue;
 | ||||
| +		}
 | ||||
| +
 | ||||
|  		value = readl(&ippc->u3_ctrl_p[i]); | ||||
|  		value &= ~(CTRL_U3_PORT_PDN | CTRL_U3_PORT_DIS); | ||||
|  		value |= CTRL_U3_PORT_HOST_SEL; | ||||
| @@ -126,7 +132,7 @@ static int xhci_mtk_host_enable(struct x
 | ||||
|  	check_val = STS1_SYSPLL_STABLE | STS1_REF_RST | | ||||
|  			STS1_SYS125_RST | STS1_XHCI_RST; | ||||
|   | ||||
| -	if (mtk->num_u3_ports)
 | ||||
| +	if (mtk->num_u3_ports > u3_ports_disabed)
 | ||||
|  		check_val |= STS1_U3_MAC_RST; | ||||
|   | ||||
|  	ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, | ||||
| @@ -149,8 +155,11 @@ static int xhci_mtk_host_disable(struct
 | ||||
|  	if (!mtk->has_ippc) | ||||
|  		return 0; | ||||
|   | ||||
| -	/* power down all u3 ports */
 | ||||
| +	/* power down u3 ports except skipped ones */
 | ||||
|  	for (i = 0; i < mtk->num_u3_ports; i++) { | ||||
| +		if ((0x1 << i) & mtk->u3p_dis_msk)
 | ||||
| +			continue;
 | ||||
| +
 | ||||
|  		value = readl(&ippc->u3_ctrl_p[i]); | ||||
|  		value |= CTRL_U3_PORT_PDN; | ||||
|  		writel(value, &ippc->u3_ctrl_p[i]); | ||||
| @@ -573,6 +582,9 @@ static int xhci_mtk_probe(struct platfor
 | ||||
|  	} | ||||
|   | ||||
|  	mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); | ||||
| +	/* optional property, ignore the error if it does not exist */
 | ||||
| +	of_property_read_u32(node, "mediatek,u3p-dis-msk",
 | ||||
| +			     &mtk->u3p_dis_msk);
 | ||||
|   | ||||
|  	ret = usb_wakeup_of_property_parse(mtk, node); | ||||
|  	if (ret) | ||||
| --- a/drivers/usb/host/xhci-mtk.h
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.h
 | ||||
| @@ -121,6 +121,7 @@ struct xhci_hcd_mtk {
 | ||||
|  	bool has_ippc; | ||||
|  	int num_u2_ports; | ||||
|  	int num_u3_ports; | ||||
| +	int u3p_dis_msk;
 | ||||
|  	struct regulator *vusb33; | ||||
|  	struct regulator *vbus; | ||||
|  	struct clk *sys_clk;	/* sys and mac clock */ | ||||
|  | @ -0,0 +1,86 @@ | |||
| From 25adaf94e0fcbf6c1b47cb610edb7f5c23c53139 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:37 +0800 | ||||
| Subject: [PATCH 130/224] usb: xhci-mtk: remove dummy wakeup debounce clocks | ||||
| 
 | ||||
| The wakeup debounce clocks for each ports in fact are not | ||||
| needed, so remove them. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk.c | 33 --------------------------------- | ||||
|  drivers/usb/host/xhci-mtk.h |  2 -- | ||||
|  2 files changed, 35 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -237,25 +237,8 @@ static int xhci_mtk_clks_enable(struct x
 | ||||
|  		goto sys_clk_err; | ||||
|  	} | ||||
|   | ||||
| -	if (mtk->wakeup_src) {
 | ||||
| -		ret = clk_prepare_enable(mtk->wk_deb_p0);
 | ||||
| -		if (ret) {
 | ||||
| -			dev_err(mtk->dev, "failed to enable wk_deb_p0\n");
 | ||||
| -			goto usb_p0_err;
 | ||||
| -		}
 | ||||
| -
 | ||||
| -		ret = clk_prepare_enable(mtk->wk_deb_p1);
 | ||||
| -		if (ret) {
 | ||||
| -			dev_err(mtk->dev, "failed to enable wk_deb_p1\n");
 | ||||
| -			goto usb_p1_err;
 | ||||
| -		}
 | ||||
| -	}
 | ||||
|  	return 0; | ||||
|   | ||||
| -usb_p1_err:
 | ||||
| -	clk_disable_unprepare(mtk->wk_deb_p0);
 | ||||
| -usb_p0_err:
 | ||||
| -	clk_disable_unprepare(mtk->sys_clk);
 | ||||
|  sys_clk_err: | ||||
|  	clk_disable_unprepare(mtk->ref_clk); | ||||
|  ref_clk_err: | ||||
| @@ -264,10 +247,6 @@ ref_clk_err:
 | ||||
|   | ||||
|  static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) | ||||
|  { | ||||
| -	if (mtk->wakeup_src) {
 | ||||
| -		clk_disable_unprepare(mtk->wk_deb_p1);
 | ||||
| -		clk_disable_unprepare(mtk->wk_deb_p0);
 | ||||
| -	}
 | ||||
|  	clk_disable_unprepare(mtk->sys_clk); | ||||
|  	clk_disable_unprepare(mtk->ref_clk); | ||||
|  } | ||||
| @@ -371,18 +350,6 @@ static int usb_wakeup_of_property_parse(
 | ||||
|  	if (!mtk->wakeup_src) | ||||
|  		return 0; | ||||
|   | ||||
| -	mtk->wk_deb_p0 = devm_clk_get(dev, "wakeup_deb_p0");
 | ||||
| -	if (IS_ERR(mtk->wk_deb_p0)) {
 | ||||
| -		dev_err(dev, "fail to get wakeup_deb_p0\n");
 | ||||
| -		return PTR_ERR(mtk->wk_deb_p0);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	mtk->wk_deb_p1 = devm_clk_get(dev, "wakeup_deb_p1");
 | ||||
| -	if (IS_ERR(mtk->wk_deb_p1)) {
 | ||||
| -		dev_err(dev, "fail to get wakeup_deb_p1\n");
 | ||||
| -		return PTR_ERR(mtk->wk_deb_p1);
 | ||||
| -	}
 | ||||
| -
 | ||||
|  	mtk->pericfg = syscon_regmap_lookup_by_phandle(dn, | ||||
|  						"mediatek,syscon-wakeup"); | ||||
|  	if (IS_ERR(mtk->pericfg)) { | ||||
| --- a/drivers/usb/host/xhci-mtk.h
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.h
 | ||||
| @@ -126,8 +126,6 @@ struct xhci_hcd_mtk {
 | ||||
|  	struct regulator *vbus; | ||||
|  	struct clk *sys_clk;	/* sys and mac clock */ | ||||
|  	struct clk *ref_clk; | ||||
| -	struct clk *wk_deb_p0;	/* port0's wakeup debounce clock */
 | ||||
| -	struct clk *wk_deb_p1;
 | ||||
|  	struct regmap *pericfg; | ||||
|  	struct phy **phys; | ||||
|  	int num_phys; | ||||
|  | @ -0,0 +1,139 @@ | |||
| From 9dce908d64ffb8b0ab71cb3a4b79db398d2e6dc3 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:38 +0800 | ||||
| Subject: [PATCH 131/224] usb: xhci-mtk: add optional mcu and dma bus clocks | ||||
| 
 | ||||
| There are mcu_bus and dma_bus clocks needed to be controlled by | ||||
| driver on some SoCs, so add them as optional ones | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/xhci-mtk.c | 79 ++++++++++++++++++++++++++++++++++----------- | ||||
|  drivers/usb/host/xhci-mtk.h |  2 ++ | ||||
|  2 files changed, 62 insertions(+), 19 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/xhci-mtk.c
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.c
 | ||||
| @@ -221,6 +221,44 @@ static int xhci_mtk_ssusb_config(struct
 | ||||
|  	return xhci_mtk_host_enable(mtk); | ||||
|  } | ||||
|   | ||||
| +/* ignore the error if the clock does not exist */
 | ||||
| +static struct clk *optional_clk_get(struct device *dev, const char *id)
 | ||||
| +{
 | ||||
| +	struct clk *opt_clk;
 | ||||
| +
 | ||||
| +	opt_clk = devm_clk_get(dev, id);
 | ||||
| +	/* ignore error number except EPROBE_DEFER */
 | ||||
| +	if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
 | ||||
| +		opt_clk = NULL;
 | ||||
| +
 | ||||
| +	return opt_clk;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
 | ||||
| +{
 | ||||
| +	struct device *dev = mtk->dev;
 | ||||
| +
 | ||||
| +	mtk->sys_clk = devm_clk_get(dev, "sys_ck");
 | ||||
| +	if (IS_ERR(mtk->sys_clk)) {
 | ||||
| +		dev_err(dev, "fail to get sys_ck\n");
 | ||||
| +		return PTR_ERR(mtk->sys_clk);
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	mtk->ref_clk = optional_clk_get(dev, "ref_ck");
 | ||||
| +	if (IS_ERR(mtk->ref_clk))
 | ||||
| +		return PTR_ERR(mtk->ref_clk);
 | ||||
| +
 | ||||
| +	mtk->mcu_clk = optional_clk_get(dev, "mcu_ck");
 | ||||
| +	if (IS_ERR(mtk->mcu_clk))
 | ||||
| +		return PTR_ERR(mtk->mcu_clk);
 | ||||
| +
 | ||||
| +	mtk->dma_clk = optional_clk_get(dev, "dma_ck");
 | ||||
| +	if (IS_ERR(mtk->dma_clk))
 | ||||
| +		return PTR_ERR(mtk->dma_clk);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) | ||||
|  { | ||||
|  	int ret; | ||||
| @@ -237,16 +275,34 @@ static int xhci_mtk_clks_enable(struct x
 | ||||
|  		goto sys_clk_err; | ||||
|  	} | ||||
|   | ||||
| +	ret = clk_prepare_enable(mtk->mcu_clk);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(mtk->dev, "failed to enable mcu_clk\n");
 | ||||
| +		goto mcu_clk_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	ret = clk_prepare_enable(mtk->dma_clk);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(mtk->dev, "failed to enable dma_clk\n");
 | ||||
| +		goto dma_clk_err;
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	return 0; | ||||
|   | ||||
| +dma_clk_err:
 | ||||
| +	clk_disable_unprepare(mtk->mcu_clk);
 | ||||
| +mcu_clk_err:
 | ||||
| +	clk_disable_unprepare(mtk->sys_clk);
 | ||||
|  sys_clk_err: | ||||
|  	clk_disable_unprepare(mtk->ref_clk); | ||||
|  ref_clk_err: | ||||
| -	return -EINVAL;
 | ||||
| +	return ret;
 | ||||
|  } | ||||
|   | ||||
|  static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) | ||||
|  { | ||||
| +	clk_disable_unprepare(mtk->dma_clk);
 | ||||
| +	clk_disable_unprepare(mtk->mcu_clk);
 | ||||
|  	clk_disable_unprepare(mtk->sys_clk); | ||||
|  	clk_disable_unprepare(mtk->ref_clk); | ||||
|  } | ||||
| @@ -529,24 +585,9 @@ static int xhci_mtk_probe(struct platfor
 | ||||
|  		return PTR_ERR(mtk->vusb33); | ||||
|  	} | ||||
|   | ||||
| -	mtk->sys_clk = devm_clk_get(dev, "sys_ck");
 | ||||
| -	if (IS_ERR(mtk->sys_clk)) {
 | ||||
| -		dev_err(dev, "fail to get sys_ck\n");
 | ||||
| -		return PTR_ERR(mtk->sys_clk);
 | ||||
| -	}
 | ||||
| -
 | ||||
| -	/*
 | ||||
| -	 * reference clock is usually a "fixed-clock", make it optional
 | ||||
| -	 * for backward compatibility and ignore the error if it does
 | ||||
| -	 * not exist.
 | ||||
| -	 */
 | ||||
| -	mtk->ref_clk = devm_clk_get(dev, "ref_ck");
 | ||||
| -	if (IS_ERR(mtk->ref_clk)) {
 | ||||
| -		if (PTR_ERR(mtk->ref_clk) == -EPROBE_DEFER)
 | ||||
| -			return -EPROBE_DEFER;
 | ||||
| -
 | ||||
| -		mtk->ref_clk = NULL;
 | ||||
| -	}
 | ||||
| +	ret = xhci_mtk_clks_get(mtk);
 | ||||
| +	if (ret)
 | ||||
| +		return ret;
 | ||||
|   | ||||
|  	mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); | ||||
|  	/* optional property, ignore the error if it does not exist */ | ||||
| --- a/drivers/usb/host/xhci-mtk.h
 | ||||
| +++ b/drivers/usb/host/xhci-mtk.h
 | ||||
| @@ -126,6 +126,8 @@ struct xhci_hcd_mtk {
 | ||||
|  	struct regulator *vbus; | ||||
|  	struct clk *sys_clk;	/* sys and mac clock */ | ||||
|  	struct clk *ref_clk; | ||||
| +	struct clk *mcu_clk;
 | ||||
| +	struct clk *dma_clk;
 | ||||
|  	struct regmap *pericfg; | ||||
|  	struct phy **phys; | ||||
|  	int num_phys; | ||||
|  | @ -0,0 +1,32 @@ | |||
| From d975bd8976c4d19fbfbaafe269dd466e281a2e3e Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:39 +0800 | ||||
| Subject: [PATCH 132/224] usb: host: modify description for MTK xHCI config | ||||
| 
 | ||||
| Due to all MediaTek SoCs with xHCI host controller use this | ||||
| driver, remove limitation for specific SoCs | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  drivers/usb/host/Kconfig | 4 ++-- | ||||
|  1 file changed, 2 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/usb/host/Kconfig
 | ||||
| +++ b/drivers/usb/host/Kconfig
 | ||||
| @@ -45,12 +45,12 @@ config USB_XHCI_PLATFORM
 | ||||
|  	  If unsure, say N. | ||||
|   | ||||
|  config USB_XHCI_MTK | ||||
| -	tristate "xHCI support for Mediatek MT65xx/MT7621"
 | ||||
| +	tristate "xHCI support for MediaTek SoCs"
 | ||||
|  	select MFD_SYSCON | ||||
|  	depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || COMPILE_TEST | ||||
|  	---help--- | ||||
|  	  Say 'Y' to enable the support for the xHCI host controller | ||||
| -	  found in Mediatek MT65xx SoCs.
 | ||||
| +	  found in MediaTek SoCs.
 | ||||
|  	  If unsure, say N. | ||||
|   | ||||
|  config USB_XHCI_MVEBU | ||||
|  | @ -0,0 +1,25 @@ | |||
| From 3a2dce7d84793ec60cff173e17e3669acaade8c9 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:40 +0800 | ||||
| Subject: [PATCH 133/224] dt-bindings: usb: mtk-xhci: add a optional property | ||||
|  to disable u3ports | ||||
| 
 | ||||
| Add a new optional property to disable u3ports | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt | 2 ++ | ||||
|  1 file changed, 2 insertions(+) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | ||||
| @@ -38,6 +38,8 @@ Optional properties:
 | ||||
|  	mode; | ||||
|   - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup | ||||
|  	control register, it depends on "mediatek,wakeup-src". | ||||
| + - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 | ||||
| +	bit1 for u3port1, ... etc;
 | ||||
|   - vbus-supply : reference to the VBUS regulator; | ||||
|   - usb3-lpm-capable : supports USB3.0 LPM | ||||
|   - pinctrl-names : a pinctrl state named "default" must be defined | ||||
|  | @ -0,0 +1,58 @@ | |||
| From a96468412cac8abd66667c322fbcda756cc3abc9 Mon Sep 17 00:00:00 2001 | ||||
| From: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Date: Fri, 13 Oct 2017 16:26:41 +0800 | ||||
| Subject: [PATCH 134/224] dt-bindings: usb: mtk-xhci: remove dummy clocks and | ||||
|  add optional ones | ||||
| 
 | ||||
| Remove dummy clocks for usb wakeup and add optional ones for | ||||
| MCU_BUS_CK and DMA_BUS_CK. | ||||
| 
 | ||||
| Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||||
| ---
 | ||||
|  .../devicetree/bindings/usb/mediatek,mtk-xhci.txt      | 18 ++++++++---------- | ||||
|  1 file changed, 8 insertions(+), 10 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | ||||
| @@ -26,10 +26,11 @@ Required properties:
 | ||||
|   - clocks : a list of phandle + clock-specifier pairs, one for each | ||||
|  	entry in clock-names | ||||
|   - clock-names : must contain | ||||
| -	"sys_ck": for clock of xHCI MAC
 | ||||
| -	"ref_ck": for reference clock of xHCI MAC
 | ||||
| -	"wakeup_deb_p0": for USB wakeup debounce clock of port0
 | ||||
| -	"wakeup_deb_p1": for USB wakeup debounce clock of port1
 | ||||
| +	"sys_ck": controller clock used by normal mode,
 | ||||
| +	the following ones are optional:
 | ||||
| +	"ref_ck": reference clock used by low power mode etc,
 | ||||
| +	"mcu_ck": mcu_bus clock for register access,
 | ||||
| +	"dma_ck": dma_bus clock for data transfer by DMA
 | ||||
|   | ||||
|   - phys : a list of phandle + phy specifier pairs | ||||
|   | ||||
| @@ -57,9 +58,7 @@ usb30: usb@11270000 {
 | ||||
|  	clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, | ||||
|  		 <&pericfg CLK_PERI_USB0>, | ||||
|  		 <&pericfg CLK_PERI_USB1>; | ||||
| -	clock-names = "sys_ck", "ref_ck",
 | ||||
| -		      "wakeup_deb_p0",
 | ||||
| -		      "wakeup_deb_p1";
 | ||||
| +	clock-names = "sys_ck", "ref_ck";
 | ||||
|  	phys = <&phy_port0 PHY_TYPE_USB3>, | ||||
|  	       <&phy_port1 PHY_TYPE_USB2>; | ||||
|  	vusb33-supply = <&mt6397_vusb_reg>; | ||||
| @@ -91,9 +90,8 @@ Required properties:
 | ||||
|   | ||||
|   - clocks : a list of phandle + clock-specifier pairs, one for each | ||||
|  	entry in clock-names | ||||
| - - clock-names : must be
 | ||||
| -	"sys_ck": for clock of xHCI MAC
 | ||||
| -	"ref_ck": for reference clock of xHCI MAC
 | ||||
| + - clock-names : must contain "sys_ck", and the following ones are optional:
 | ||||
| +	"ref_ck", "mcu_ck" and "dma_ck"
 | ||||
|   | ||||
|  Optional properties: | ||||
|   - vbus-supply : reference to the VBUS regulator; | ||||
|  | @ -0,0 +1,42 @@ | |||
| From 2af9a8582cb28e786a8cbd913f41e6db9adcf3dc Mon Sep 17 00:00:00 2001 | ||||
| From: Guochun Mao <guochun.mao@mediatek.com> | ||||
| Date: Thu, 21 Sep 2017 20:45:05 +0800 | ||||
| Subject: [PATCH 135/224] dt-bindings: mtd: add new compatible strings and | ||||
|  improve description | ||||
| 
 | ||||
| Add "mediatak,mt2712-nor" and "mediatek,mt7622-nor" | ||||
| for nor flash node's compatible strings. | ||||
| Explicate the fallback compatible. | ||||
| 
 | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Guochun Mao <guochun.mao@mediatek.com> | ||||
| Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++++++++------ | ||||
|  1 file changed, 9 insertions(+), 6 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
 | ||||
| @@ -1,13 +1,16 @@
 | ||||
|  * Serial NOR flash controller for MTK MT81xx (and similar) | ||||
|   | ||||
|  Required properties: | ||||
| -- compatible: 	  The possible values are:
 | ||||
| -		  "mediatek,mt2701-nor"
 | ||||
| -		  "mediatek,mt7623-nor"
 | ||||
| +- compatible: 	  For mt8173, compatible should be "mediatek,mt8173-nor",
 | ||||
| +		  and it's the fallback compatible for other Soc.
 | ||||
| +		  For every other SoC, should contain both the SoC-specific compatible
 | ||||
| +		  string and "mediatek,mt8173-nor".
 | ||||
| +		  The possible values are:
 | ||||
| +		  "mediatek,mt2701-nor", "mediatek,mt8173-nor"
 | ||||
| +		  "mediatek,mt2712-nor", "mediatek,mt8173-nor"
 | ||||
| +		  "mediatek,mt7622-nor", "mediatek,mt8173-nor"
 | ||||
| +		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
 | ||||
|  		  "mediatek,mt8173-nor" | ||||
| -		  For mt8173, compatible should be "mediatek,mt8173-nor".
 | ||||
| -		  For every other SoC, should contain both the SoC-specific compatible string
 | ||||
| -		  and "mediatek,mt8173-nor".
 | ||||
|  - reg: 		  physical base address and length of the controller's register | ||||
|  - clocks: 	  the phandle of the clocks needed by the nor controller | ||||
|  - clock-names: 	  the names of the clocks | ||||
|  | @ -0,0 +1,128 @@ | |||
| From 8947f8cd407a55db816cd03fc03b59096210978e Mon Sep 17 00:00:00 2001 | ||||
| From: Guochun Mao <guochun.mao@mediatek.com> | ||||
| Date: Thu, 21 Sep 2017 20:45:06 +0800 | ||||
| Subject: [PATCH 136/224] mtd: mtk-nor: add suspend/resume support | ||||
| 
 | ||||
| Abstract functions of clock setting, to avoid duplicated code, | ||||
| these functions been used in new feature. | ||||
| Implement suspend/resume functions. | ||||
| 
 | ||||
| Signed-off-by: Guochun Mao <guochun.mao@mediatek.com> | ||||
| Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> | ||||
| ---
 | ||||
|  drivers/mtd/spi-nor/mtk-quadspi.c | 70 ++++++++++++++++++++++++++++++++------- | ||||
|  1 file changed, 58 insertions(+), 12 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mtd/spi-nor/mtk-quadspi.c
 | ||||
| +++ b/drivers/mtd/spi-nor/mtk-quadspi.c
 | ||||
| @@ -404,6 +404,29 @@ static int mt8173_nor_write_reg(struct s
 | ||||
|  	return ret; | ||||
|  } | ||||
|   | ||||
| +static void mt8173_nor_disable_clk(struct mt8173_nor *mt8173_nor)
 | ||||
| +{
 | ||||
| +	clk_disable_unprepare(mt8173_nor->spi_clk);
 | ||||
| +	clk_disable_unprepare(mt8173_nor->nor_clk);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mt8173_nor_enable_clk(struct mt8173_nor *mt8173_nor)
 | ||||
| +{
 | ||||
| +	int ret;
 | ||||
| +
 | ||||
| +	ret = clk_prepare_enable(mt8173_nor->spi_clk);
 | ||||
| +	if (ret)
 | ||||
| +		return ret;
 | ||||
| +
 | ||||
| +	ret = clk_prepare_enable(mt8173_nor->nor_clk);
 | ||||
| +	if (ret) {
 | ||||
| +		clk_disable_unprepare(mt8173_nor->spi_clk);
 | ||||
| +		return ret;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
|  static int mtk_nor_init(struct mt8173_nor *mt8173_nor, | ||||
|  			struct device_node *flash_node) | ||||
|  { | ||||
| @@ -468,15 +491,11 @@ static int mtk_nor_drv_probe(struct plat
 | ||||
|  		return PTR_ERR(mt8173_nor->nor_clk); | ||||
|   | ||||
|  	mt8173_nor->dev = &pdev->dev; | ||||
| -	ret = clk_prepare_enable(mt8173_nor->spi_clk);
 | ||||
| +
 | ||||
| +	ret = mt8173_nor_enable_clk(mt8173_nor);
 | ||||
|  	if (ret) | ||||
|  		return ret; | ||||
|   | ||||
| -	ret = clk_prepare_enable(mt8173_nor->nor_clk);
 | ||||
| -	if (ret) {
 | ||||
| -		clk_disable_unprepare(mt8173_nor->spi_clk);
 | ||||
| -		return ret;
 | ||||
| -	}
 | ||||
|  	/* only support one attached flash */ | ||||
|  	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL); | ||||
|  	if (!flash_np) { | ||||
| @@ -487,10 +506,9 @@ static int mtk_nor_drv_probe(struct plat
 | ||||
|  	ret = mtk_nor_init(mt8173_nor, flash_np); | ||||
|   | ||||
|  nor_free: | ||||
| -	if (ret) {
 | ||||
| -		clk_disable_unprepare(mt8173_nor->spi_clk);
 | ||||
| -		clk_disable_unprepare(mt8173_nor->nor_clk);
 | ||||
| -	}
 | ||||
| +	if (ret)
 | ||||
| +		mt8173_nor_disable_clk(mt8173_nor);
 | ||||
| +
 | ||||
|  	return ret; | ||||
|  } | ||||
|   | ||||
| @@ -498,11 +516,38 @@ static int mtk_nor_drv_remove(struct pla
 | ||||
|  { | ||||
|  	struct mt8173_nor *mt8173_nor = platform_get_drvdata(pdev); | ||||
|   | ||||
| -	clk_disable_unprepare(mt8173_nor->spi_clk);
 | ||||
| -	clk_disable_unprepare(mt8173_nor->nor_clk);
 | ||||
| +	mt8173_nor_disable_clk(mt8173_nor);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +#ifdef CONFIG_PM_SLEEP
 | ||||
| +static int mtk_nor_suspend(struct device *dev)
 | ||||
| +{
 | ||||
| +	struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	mt8173_nor_disable_clk(mt8173_nor);
 | ||||
| +
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| +static int mtk_nor_resume(struct device *dev)
 | ||||
| +{
 | ||||
| +	struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	return mt8173_nor_enable_clk(mt8173_nor);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static const struct dev_pm_ops mtk_nor_dev_pm_ops = {
 | ||||
| +	.suspend = mtk_nor_suspend,
 | ||||
| +	.resume = mtk_nor_resume,
 | ||||
| +};
 | ||||
| +
 | ||||
| +#define MTK_NOR_DEV_PM_OPS	(&mtk_nor_dev_pm_ops)
 | ||||
| +#else
 | ||||
| +#define MTK_NOR_DEV_PM_OPS	NULL
 | ||||
| +#endif
 | ||||
| +
 | ||||
|  static const struct of_device_id mtk_nor_of_ids[] = { | ||||
|  	{ .compatible = "mediatek,mt8173-nor"}, | ||||
|  	{ /* sentinel */ } | ||||
| @@ -514,6 +559,7 @@ static struct platform_driver mtk_nor_dr
 | ||||
|  	.remove = mtk_nor_drv_remove, | ||||
|  	.driver = { | ||||
|  		.name = "mtk-nor", | ||||
| +		.pm = MTK_NOR_DEV_PM_OPS,
 | ||||
|  		.of_match_table = mtk_nor_of_ids, | ||||
|  	}, | ||||
|  }; | ||||
|  | @ -0,0 +1,41 @@ | |||
| From 3254edde244fcbcce3bf4da1ade9db2db558ae28 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Mon, 23 Oct 2017 15:16:44 +0800 | ||||
| Subject: [PATCH 137/224] dt-bindings: rtc: mediatek: add bindings for MediaTek | ||||
|  SoC based RTC | ||||
| 
 | ||||
| Add device-tree binding for MediaTek SoC based RTC | ||||
| 
 | ||||
| Cc: devicetree@vger.kernel.org | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> | ||||
| ---
 | ||||
|  .../devicetree/bindings/rtc/rtc-mt7622.txt          | 21 +++++++++++++++++++++ | ||||
|  1 file changed, 21 insertions(+) | ||||
|  create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt7622.txt | ||||
| 
 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/rtc/rtc-mt7622.txt
 | ||||
| @@ -0,0 +1,21 @@
 | ||||
| +Device-Tree bindings for MediaTek SoC based RTC
 | ||||
| +
 | ||||
| +Required properties:
 | ||||
| +- compatible	    : Should be
 | ||||
| +			"mediatek,mt7622-rtc", "mediatek,soc-rtc" : for MT7622 SoC
 | ||||
| +- reg 		    : Specifies base physical address and size of the registers;
 | ||||
| +- interrupts	    : Should contain the interrupt for RTC alarm;
 | ||||
| +- clocks	    : Specifies list of clock specifiers, corresponding to
 | ||||
| +		      entries in clock-names property;
 | ||||
| +- clock-names	    : Should contain "rtc" entries
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +rtc: rtc@10212800 {
 | ||||
| +	compatible = "mediatek,mt7622-rtc",
 | ||||
| +		     "mediatek,soc-rtc";
 | ||||
| +	reg = <0 0x10212800 0 0x200>;
 | ||||
| +	interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_LOW>;
 | ||||
| +	clocks = <&topckgen CLK_TOP_RTC>;
 | ||||
| +	clock-names = "rtc";
 | ||||
| +};
 | ||||
|  | @ -0,0 +1,471 @@ | |||
| From 4cf0b74c175cb5cb751e449223c0baafc2f98499 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Mon, 23 Oct 2017 15:16:45 +0800 | ||||
| Subject: [PATCH 138/224] rtc: mediatek: add driver for RTC on MT7622 SoC | ||||
| 
 | ||||
| This patch introduces the driver for the RTC on MT7622 SoC. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Reviewed-by: Yingjoe Chen <yingjoe.chen@mediatek.com> | ||||
| Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/rtc/Kconfig      |  10 ++ | ||||
|  drivers/rtc/Makefile     |   1 + | ||||
|  drivers/rtc/rtc-mt7622.c | 422 +++++++++++++++++++++++++++++++++++++++++++++++ | ||||
|  3 files changed, 433 insertions(+) | ||||
|  create mode 100644 drivers/rtc/rtc-mt7622.c | ||||
| 
 | ||||
| --- a/drivers/rtc/Kconfig
 | ||||
| +++ b/drivers/rtc/Kconfig
 | ||||
| @@ -1715,6 +1715,16 @@ config RTC_DRV_MT6397
 | ||||
|   | ||||
|  	  If you want to use Mediatek(R) RTC interface, select Y or M here. | ||||
|   | ||||
| +config RTC_DRV_MT7622
 | ||||
| +	tristate "MediaTek SoC based RTC"
 | ||||
| +	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
| +	help
 | ||||
| +	  This enables support for the real time clock built in the MediaTek
 | ||||
| +	  SoCs.
 | ||||
| +
 | ||||
| +	  This drive can also be built as a module. If so, the module
 | ||||
| +	  will be called rtc-mt7622.
 | ||||
| +
 | ||||
|  config RTC_DRV_XGENE | ||||
|  	tristate "APM X-Gene RTC" | ||||
|  	depends on HAS_IOMEM | ||||
| --- a/drivers/rtc/Makefile
 | ||||
| +++ b/drivers/rtc/Makefile
 | ||||
| @@ -103,6 +103,7 @@ obj-$(CONFIG_RTC_DRV_MPC5121)	+= rtc-mpc
 | ||||
|  obj-$(CONFIG_RTC_DRV_VRTC)	+= rtc-mrst.o | ||||
|  obj-$(CONFIG_RTC_DRV_MSM6242)	+= rtc-msm6242.o | ||||
|  obj-$(CONFIG_RTC_DRV_MT6397)	+= rtc-mt6397.o | ||||
| +obj-$(CONFIG_RTC_DRV_MT7622)	+= rtc-mt7622.o
 | ||||
|  obj-$(CONFIG_RTC_DRV_MV)	+= rtc-mv.o | ||||
|  obj-$(CONFIG_RTC_DRV_MXC)	+= rtc-mxc.o | ||||
|  obj-$(CONFIG_RTC_DRV_NUC900)	+= rtc-nuc900.o | ||||
| --- /dev/null
 | ||||
| +++ b/drivers/rtc/rtc-mt7622.c
 | ||||
| @@ -0,0 +1,422 @@
 | ||||
| +/*
 | ||||
| + * Driver for MediaTek SoC based RTC
 | ||||
| + *
 | ||||
| + * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
 | ||||
| + *
 | ||||
| + * 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.
 | ||||
| + */
 | ||||
| +
 | ||||
| +#include <linux/clk.h>
 | ||||
| +#include <linux/interrupt.h>
 | ||||
| +#include <linux/module.h>
 | ||||
| +#include <linux/of_address.h>
 | ||||
| +#include <linux/of_device.h>
 | ||||
| +#include <linux/platform_device.h>
 | ||||
| +#include <linux/rtc.h>
 | ||||
| +
 | ||||
| +#define MTK_RTC_DEV KBUILD_MODNAME
 | ||||
| +
 | ||||
| +#define MTK_RTC_PWRCHK1		0x4
 | ||||
| +#define	RTC_PWRCHK1_MAGIC	0xc6
 | ||||
| +
 | ||||
| +#define MTK_RTC_PWRCHK2		0x8
 | ||||
| +#define	RTC_PWRCHK2_MAGIC	0x9a
 | ||||
| +
 | ||||
| +#define MTK_RTC_KEY		0xc
 | ||||
| +#define	RTC_KEY_MAGIC		0x59
 | ||||
| +
 | ||||
| +#define MTK_RTC_PROT1		0x10
 | ||||
| +#define	RTC_PROT1_MAGIC		0xa3
 | ||||
| +
 | ||||
| +#define MTK_RTC_PROT2		0x14
 | ||||
| +#define	RTC_PROT2_MAGIC		0x57
 | ||||
| +
 | ||||
| +#define MTK_RTC_PROT3		0x18
 | ||||
| +#define	RTC_PROT3_MAGIC		0x67
 | ||||
| +
 | ||||
| +#define MTK_RTC_PROT4		0x1c
 | ||||
| +#define	RTC_PROT4_MAGIC		0xd2
 | ||||
| +
 | ||||
| +#define MTK_RTC_CTL		0x20
 | ||||
| +#define	RTC_RC_STOP		BIT(0)
 | ||||
| +
 | ||||
| +#define MTK_RTC_DEBNCE		0x2c
 | ||||
| +#define	RTC_DEBNCE_MASK		GENMASK(2, 0)
 | ||||
| +
 | ||||
| +#define MTK_RTC_INT		0x30
 | ||||
| +#define RTC_INT_AL_STA		BIT(4)
 | ||||
| +
 | ||||
| +/*
 | ||||
| + * Ranges from 0x40 to 0x78 provide RTC time setup for year, month,
 | ||||
| + * day of month, day of week, hour, minute and second.
 | ||||
| + */
 | ||||
| +#define MTK_RTC_TREG(_t, _f)	(0x40 + (0x4 * (_f)) + ((_t) * 0x20))
 | ||||
| +
 | ||||
| +#define MTK_RTC_AL_CTL		0x7c
 | ||||
| +#define	RTC_AL_EN		BIT(0)
 | ||||
| +#define	RTC_AL_ALL		GENMASK(7, 0)
 | ||||
| +
 | ||||
| +/*
 | ||||
| + * The offset is used in the translation for the year between in struct
 | ||||
| + * rtc_time and in hardware register MTK_RTC_TREG(x,MTK_YEA)
 | ||||
| + */
 | ||||
| +#define MTK_RTC_TM_YR_OFFSET	100
 | ||||
| +
 | ||||
| +/*
 | ||||
| + * The lowest value for the valid tm_year. RTC hardware would take incorrectly
 | ||||
| + * tm_year 100 as not a leap year and thus it is also required being excluded
 | ||||
| + * from the valid options.
 | ||||
| + */
 | ||||
| +#define MTK_RTC_TM_YR_L		(MTK_RTC_TM_YR_OFFSET + 1)
 | ||||
| +
 | ||||
| +/*
 | ||||
| + * The most year the RTC can hold is 99 and the next to 99 in year register
 | ||||
| + * would be wraparound to 0, for MT7622.
 | ||||
| + */
 | ||||
| +#define MTK_RTC_HW_YR_LIMIT	99
 | ||||
| +
 | ||||
| +/* The highest value for the valid tm_year */
 | ||||
| +#define MTK_RTC_TM_YR_H		(MTK_RTC_TM_YR_OFFSET + MTK_RTC_HW_YR_LIMIT)
 | ||||
| +
 | ||||
| +/* Simple macro helps to check whether the hardware supports the tm_year */
 | ||||
| +#define MTK_RTC_TM_YR_VALID(_y)	((_y) >= MTK_RTC_TM_YR_L && \
 | ||||
| +				 (_y) <= MTK_RTC_TM_YR_H)
 | ||||
| +
 | ||||
| +/* Types of the function the RTC provides are time counter and alarm. */
 | ||||
| +enum {
 | ||||
| +	MTK_TC,
 | ||||
| +	MTK_AL,
 | ||||
| +};
 | ||||
| +
 | ||||
| +/* Indexes are used for the pointer to relevant registers in MTK_RTC_TREG */
 | ||||
| +enum {
 | ||||
| +	MTK_YEA,
 | ||||
| +	MTK_MON,
 | ||||
| +	MTK_DOM,
 | ||||
| +	MTK_DOW,
 | ||||
| +	MTK_HOU,
 | ||||
| +	MTK_MIN,
 | ||||
| +	MTK_SEC
 | ||||
| +};
 | ||||
| +
 | ||||
| +struct mtk_rtc {
 | ||||
| +	struct rtc_device *rtc;
 | ||||
| +	void __iomem *base;
 | ||||
| +	int irq;
 | ||||
| +	struct clk *clk;
 | ||||
| +};
 | ||||
| +
 | ||||
| +static void mtk_w32(struct mtk_rtc *rtc, u32 reg, u32 val)
 | ||||
| +{
 | ||||
| +	writel_relaxed(val, rtc->base + reg);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static u32 mtk_r32(struct mtk_rtc *rtc, u32 reg)
 | ||||
| +{
 | ||||
| +	return readl_relaxed(rtc->base + reg);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_rmw(struct mtk_rtc *rtc, u32 reg, u32 mask, u32 set)
 | ||||
| +{
 | ||||
| +	u32 val;
 | ||||
| +
 | ||||
| +	val = mtk_r32(rtc, reg);
 | ||||
| +	val &= ~mask;
 | ||||
| +	val |= set;
 | ||||
| +	mtk_w32(rtc, reg, val);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_set(struct mtk_rtc *rtc, u32 reg, u32 val)
 | ||||
| +{
 | ||||
| +	mtk_rmw(rtc, reg, 0, val);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_clr(struct mtk_rtc *rtc, u32 reg, u32 val)
 | ||||
| +{
 | ||||
| +	mtk_rmw(rtc, reg, val, 0);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_rtc_hw_init(struct mtk_rtc *hw)
 | ||||
| +{
 | ||||
| +	/* The setup of the init sequence is for allowing RTC got to work */
 | ||||
| +	mtk_w32(hw, MTK_RTC_PWRCHK1, RTC_PWRCHK1_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_PWRCHK2, RTC_PWRCHK2_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_KEY, RTC_KEY_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_PROT1, RTC_PROT1_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_PROT2, RTC_PROT2_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_PROT3, RTC_PROT3_MAGIC);
 | ||||
| +	mtk_w32(hw, MTK_RTC_PROT4, RTC_PROT4_MAGIC);
 | ||||
| +	mtk_rmw(hw, MTK_RTC_DEBNCE, RTC_DEBNCE_MASK, 0);
 | ||||
| +	mtk_clr(hw, MTK_RTC_CTL, RTC_RC_STOP);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_rtc_get_alarm_or_time(struct mtk_rtc *hw, struct rtc_time *tm,
 | ||||
| +				      int time_alarm)
 | ||||
| +{
 | ||||
| +	u32 year, mon, mday, wday, hour, min, sec;
 | ||||
| +
 | ||||
| +	/*
 | ||||
| +	 * Read again until the field of the second is not changed which
 | ||||
| +	 * ensures all fields in the consistent state. Note that MTK_SEC must
 | ||||
| +	 * be read first. In this way, it guarantees the others remain not
 | ||||
| +	 * changed when the results for two MTK_SEC consecutive reads are same.
 | ||||
| +	 */
 | ||||
| +	do {
 | ||||
| +		sec = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC));
 | ||||
| +		min = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MIN));
 | ||||
| +		hour = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_HOU));
 | ||||
| +		wday = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOW));
 | ||||
| +		mday = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOM));
 | ||||
| +		mon = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MON));
 | ||||
| +		year = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_YEA));
 | ||||
| +	} while (sec != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC)));
 | ||||
| +
 | ||||
| +	tm->tm_sec  = sec;
 | ||||
| +	tm->tm_min  = min;
 | ||||
| +	tm->tm_hour = hour;
 | ||||
| +	tm->tm_wday = wday;
 | ||||
| +	tm->tm_mday = mday;
 | ||||
| +	tm->tm_mon  = mon - 1;
 | ||||
| +
 | ||||
| +	/* Rebase to the absolute year which userspace queries */
 | ||||
| +	tm->tm_year = year + MTK_RTC_TM_YR_OFFSET;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static void mtk_rtc_set_alarm_or_time(struct mtk_rtc *hw, struct rtc_time *tm,
 | ||||
| +				      int time_alarm)
 | ||||
| +{
 | ||||
| +	u32 year;
 | ||||
| +
 | ||||
| +	/* Rebase to the relative year which RTC hardware requires */
 | ||||
| +	year = tm->tm_year - MTK_RTC_TM_YR_OFFSET;
 | ||||
| +
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_YEA), year);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_MON), tm->tm_mon + 1);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_DOW), tm->tm_wday);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_DOM), tm->tm_mday);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_HOU), tm->tm_hour);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_MIN), tm->tm_min);
 | ||||
| +	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC), tm->tm_sec);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static irqreturn_t mtk_rtc_alarmirq(int irq, void *id)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = (struct mtk_rtc *)id;
 | ||||
| +	u32 irq_sta;
 | ||||
| +
 | ||||
| +	irq_sta = mtk_r32(hw, MTK_RTC_INT);
 | ||||
| +	if (irq_sta & RTC_INT_AL_STA) {
 | ||||
| +		/* Stop alarm also implicitly disables the alarm interrupt */
 | ||||
| +		mtk_w32(hw, MTK_RTC_AL_CTL, 0);
 | ||||
| +		rtc_update_irq(hw->rtc, 1, RTC_IRQF | RTC_AF);
 | ||||
| +
 | ||||
| +		/* Ack alarm interrupt status */
 | ||||
| +		mtk_w32(hw, MTK_RTC_INT, RTC_INT_AL_STA);
 | ||||
| +		return IRQ_HANDLED;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return IRQ_NONE;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_gettime(struct device *dev, struct rtc_time *tm)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	mtk_rtc_get_alarm_or_time(hw, tm, MTK_TC);
 | ||||
| +
 | ||||
| +	return rtc_valid_tm(tm);
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_settime(struct device *dev, struct rtc_time *tm)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	if (!MTK_RTC_TM_YR_VALID(tm->tm_year))
 | ||||
| +		return -EINVAL;
 | ||||
| +
 | ||||
| +	/* Stop time counter before setting a new one*/
 | ||||
| +	mtk_set(hw, MTK_RTC_CTL, RTC_RC_STOP);
 | ||||
| +
 | ||||
| +	mtk_rtc_set_alarm_or_time(hw, tm, MTK_TC);
 | ||||
| +
 | ||||
| +	/* Restart the time counter */
 | ||||
| +	mtk_clr(hw, MTK_RTC_CTL, RTC_RC_STOP);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +	struct rtc_time *alrm_tm = &wkalrm->time;
 | ||||
| +
 | ||||
| +	mtk_rtc_get_alarm_or_time(hw, alrm_tm, MTK_AL);
 | ||||
| +
 | ||||
| +	wkalrm->enabled = !!(mtk_r32(hw, MTK_RTC_AL_CTL) & RTC_AL_EN);
 | ||||
| +	wkalrm->pending = !!(mtk_r32(hw, MTK_RTC_INT) & RTC_INT_AL_STA);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +	struct rtc_time *alrm_tm = &wkalrm->time;
 | ||||
| +
 | ||||
| +	if (!MTK_RTC_TM_YR_VALID(alrm_tm->tm_year))
 | ||||
| +		return -EINVAL;
 | ||||
| +
 | ||||
| +	/*
 | ||||
| +	 * Stop the alarm also implicitly including disables interrupt before
 | ||||
| +	 * setting a new one.
 | ||||
| +	 */
 | ||||
| +	mtk_clr(hw, MTK_RTC_AL_CTL, RTC_AL_EN);
 | ||||
| +
 | ||||
| +	/*
 | ||||
| +	 * Avoid contention between mtk_rtc_setalarm and IRQ handler so that
 | ||||
| +	 * disabling the interrupt and awaiting for pending IRQ handler to
 | ||||
| +	 * complete.
 | ||||
| +	 */
 | ||||
| +	synchronize_irq(hw->irq);
 | ||||
| +
 | ||||
| +	mtk_rtc_set_alarm_or_time(hw, alrm_tm, MTK_AL);
 | ||||
| +
 | ||||
| +	/* Restart the alarm with the new setup */
 | ||||
| +	mtk_w32(hw, MTK_RTC_AL_CTL, RTC_AL_ALL);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static const struct rtc_class_ops mtk_rtc_ops = {
 | ||||
| +	.read_time		= mtk_rtc_gettime,
 | ||||
| +	.set_time		= mtk_rtc_settime,
 | ||||
| +	.read_alarm		= mtk_rtc_getalarm,
 | ||||
| +	.set_alarm		= mtk_rtc_setalarm,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct of_device_id mtk_rtc_match[] = {
 | ||||
| +	{ .compatible = "mediatek,mt7622-rtc" },
 | ||||
| +	{ .compatible = "mediatek,soc-rtc" },
 | ||||
| +	{},
 | ||||
| +};
 | ||||
| +
 | ||||
| +static int mtk_rtc_probe(struct platform_device *pdev)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw;
 | ||||
| +	struct resource *res;
 | ||||
| +	int ret;
 | ||||
| +
 | ||||
| +	hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
 | ||||
| +	if (!hw)
 | ||||
| +		return -ENOMEM;
 | ||||
| +
 | ||||
| +	platform_set_drvdata(pdev, hw);
 | ||||
| +
 | ||||
| +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | ||||
| +	hw->base = devm_ioremap_resource(&pdev->dev, res);
 | ||||
| +	if (IS_ERR(hw->base))
 | ||||
| +		return PTR_ERR(hw->base);
 | ||||
| +
 | ||||
| +	hw->clk = devm_clk_get(&pdev->dev, "rtc");
 | ||||
| +	if (IS_ERR(hw->clk)) {
 | ||||
| +		dev_err(&pdev->dev, "No clock\n");
 | ||||
| +		return PTR_ERR(hw->clk);
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	ret = clk_prepare_enable(hw->clk);
 | ||||
| +	if (ret)
 | ||||
| +		return ret;
 | ||||
| +
 | ||||
| +	hw->irq = platform_get_irq(pdev, 0);
 | ||||
| +	if (hw->irq < 0) {
 | ||||
| +		dev_err(&pdev->dev, "No IRQ resource\n");
 | ||||
| +		ret = hw->irq;
 | ||||
| +		goto err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	ret = devm_request_irq(&pdev->dev, hw->irq, mtk_rtc_alarmirq,
 | ||||
| +			       0, dev_name(&pdev->dev), hw);
 | ||||
| +	if (ret) {
 | ||||
| +		dev_err(&pdev->dev, "Can't request IRQ\n");
 | ||||
| +		goto err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	mtk_rtc_hw_init(hw);
 | ||||
| +
 | ||||
| +	device_init_wakeup(&pdev->dev, true);
 | ||||
| +
 | ||||
| +	hw->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
 | ||||
| +					   &mtk_rtc_ops, THIS_MODULE);
 | ||||
| +	if (IS_ERR(hw->rtc)) {
 | ||||
| +		ret = PTR_ERR(hw->rtc);
 | ||||
| +		dev_err(&pdev->dev, "Unable to register device\n");
 | ||||
| +		goto err;
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +err:
 | ||||
| +	clk_disable_unprepare(hw->clk);
 | ||||
| +
 | ||||
| +	return ret;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_remove(struct platform_device *pdev)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = platform_get_drvdata(pdev);
 | ||||
| +
 | ||||
| +	clk_disable_unprepare(hw->clk);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +#ifdef CONFIG_PM_SLEEP
 | ||||
| +static int mtk_rtc_suspend(struct device *dev)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	if (device_may_wakeup(dev))
 | ||||
| +		enable_irq_wake(hw->irq);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static int mtk_rtc_resume(struct device *dev)
 | ||||
| +{
 | ||||
| +	struct mtk_rtc *hw = dev_get_drvdata(dev);
 | ||||
| +
 | ||||
| +	if (device_may_wakeup(dev))
 | ||||
| +		disable_irq_wake(hw->irq);
 | ||||
| +
 | ||||
| +	return 0;
 | ||||
| +}
 | ||||
| +
 | ||||
| +static SIMPLE_DEV_PM_OPS(mtk_rtc_pm_ops, mtk_rtc_suspend, mtk_rtc_resume);
 | ||||
| +
 | ||||
| +#define MTK_RTC_PM_OPS (&mtk_rtc_pm_ops)
 | ||||
| +#else	/* CONFIG_PM */
 | ||||
| +#define MTK_RTC_PM_OPS NULL
 | ||||
| +#endif	/* CONFIG_PM */
 | ||||
| +
 | ||||
| +static struct platform_driver mtk_rtc_driver = {
 | ||||
| +	.probe	= mtk_rtc_probe,
 | ||||
| +	.remove	= mtk_rtc_remove,
 | ||||
| +	.driver = {
 | ||||
| +		.name = MTK_RTC_DEV,
 | ||||
| +		.of_match_table = mtk_rtc_match,
 | ||||
| +		.pm = MTK_RTC_PM_OPS,
 | ||||
| +	},
 | ||||
| +};
 | ||||
| +
 | ||||
| +module_platform_driver(mtk_rtc_driver);
 | ||||
| +
 | ||||
| +MODULE_DESCRIPTION("MediaTek SoC based RTC Driver");
 | ||||
| +MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
 | ||||
| +MODULE_LICENSE("GPL");
 | ||||
|  | @ -0,0 +1,39 @@ | |||
| From ff4f8c2c894f1e6b5b5551571e22b2f947545bff Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Mon, 23 Oct 2017 15:16:46 +0800 | ||||
| Subject: [PATCH 139/224] rtc: mediatek: enhance the description for MediaTek | ||||
|  PMIC based RTC | ||||
| 
 | ||||
| Give a better description for original MediaTek RTC driver as PMIC based | ||||
| RTC in order to distinguish SoC based RTC. Also turning all words with | ||||
| Mediatek to MediaTek here. | ||||
| 
 | ||||
| Cc: Eddie Huang <eddie.huang@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Acked-by: Eddie Huang <eddie.huang@mediatek.com> | ||||
| Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/rtc/Kconfig | 8 ++++---- | ||||
|  1 file changed, 4 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/rtc/Kconfig
 | ||||
| +++ b/drivers/rtc/Kconfig
 | ||||
| @@ -1706,14 +1706,14 @@ config RTC_DRV_MOXART
 | ||||
|  	   will be called rtc-moxart | ||||
|   | ||||
|  config RTC_DRV_MT6397 | ||||
| -	tristate "Mediatek Real Time Clock driver"
 | ||||
| +	tristate "MediaTek PMIC based RTC"
 | ||||
|  	depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN) | ||||
|  	help | ||||
| -	  This selects the Mediatek(R) RTC driver. RTC is part of Mediatek
 | ||||
| +	  This selects the MediaTek(R) RTC driver. RTC is part of MediaTek
 | ||||
|  	  MT6397 PMIC. You should enable MT6397 PMIC MFD before select | ||||
| -	  Mediatek(R) RTC driver.
 | ||||
| +	  MediaTek(R) RTC driver.
 | ||||
|   | ||||
| -	  If you want to use Mediatek(R) RTC interface, select Y or M here.
 | ||||
| +	  If you want to use MediaTek(R) RTC interface, select Y or M here.
 | ||||
|   | ||||
|  config RTC_DRV_MT7622 | ||||
|  	tristate "MediaTek SoC based RTC" | ||||
|  | @ -0,0 +1,31 @@ | |||
| From 71f568692a6d0a746d72c32d46a1bc09486b9dbb Mon Sep 17 00:00:00 2001 | ||||
| From: Xiaolei Li <xiaolei.li@mediatek.com> | ||||
| Date: Sat, 28 Oct 2017 14:52:23 +0800 | ||||
| Subject: [PATCH 140/224] mtd: nand: mtk: change the compile sequence of | ||||
|  mtk_nand.o and mtk_ecc.o | ||||
| 
 | ||||
| There will get mtk ecc handler during mtk nand probe now. | ||||
| If mtk ecc module is not initialized, then mtk nand probe will return | ||||
| -EPROBE_DEFER, and retry later.
 | ||||
| 
 | ||||
| Change the compile sequence of mtk_nand.o and mtk_ecc.o, initialize mtk | ||||
| ecc module before mtk nand module. This makes mtk nand module initialized | ||||
| as soon as possible. | ||||
| 
 | ||||
| Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> | ||||
| Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/mtd/nand/Makefile | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/mtd/nand/Makefile
 | ||||
| +++ b/drivers/mtd/nand/Makefile
 | ||||
| @@ -59,7 +59,7 @@ obj-$(CONFIG_MTD_NAND_SUNXI)		+= sunxi_n
 | ||||
|  obj-$(CONFIG_MTD_NAND_HISI504)	        += hisi504_nand.o | ||||
|  obj-$(CONFIG_MTD_NAND_BRCMNAND)		+= brcmnand/ | ||||
|  obj-$(CONFIG_MTD_NAND_QCOM)		+= qcom_nandc.o | ||||
| -obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_nand.o mtk_ecc.o
 | ||||
| +obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_ecc.o mtk_nand.o
 | ||||
|   | ||||
|  nand-objs := nand_base.o nand_bbt.o nand_timings.o nand_ids.o | ||||
|  nand-objs += nand_amd.o | ||||
|  | @ -0,0 +1,60 @@ | |||
| From 9ff279fef1a47a152993bf23f8d75fd233c27015 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:28 +0800 | ||||
| Subject: [PATCH 142/224] mmc: dt-bindings: Add reg/source_cg/latch-ck for | ||||
|  Mediatek MMC bindings | ||||
| 
 | ||||
| Change the comptiable for support of multi-platform | ||||
| Make compatible explicit, as MMC host of mt8173 has difference with | ||||
| mt8135(mt8173 supports hs400 and hs400_tune),so that need separate | ||||
| mt8173/mt8135 compatible name. | ||||
| Add description for reg | ||||
| Add description for source_cg | ||||
| Add description for mediatek,latch-ck | ||||
| Note that source_cg and mediatek,latch-ck are optional for some projects, | ||||
| eg, MT2701 do not have source_cg, and MT2712 do not need | ||||
| mediatek,latch-ck | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/mmc/mtk-sd.txt | 18 +++++++++++++++--- | ||||
|  1 file changed, 15 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | ||||
| @@ -7,10 +7,18 @@ This file documents differences between
 | ||||
|  and the properties used by the msdc driver. | ||||
|   | ||||
|  Required properties: | ||||
| -- compatible: Should be "mediatek,mt8173-mmc","mediatek,mt8135-mmc"
 | ||||
| +- compatible: value should be either of the following.
 | ||||
| +	"mediatek,mt8135-mmc": for mmc host ip compatible with mt8135
 | ||||
| +	"mediatek,mt8173-mmc": for mmc host ip compatible with mt8173
 | ||||
| +	"mediatek,mt2701-mmc": for mmc host ip compatible with mt2701
 | ||||
| +	"mediatek,mt2712-mmc": for mmc host ip compatible with mt2712
 | ||||
| +- reg: physical base address of the controller and length
 | ||||
|  - interrupts: Should contain MSDC interrupt number | ||||
| -- clocks: MSDC source clock, HCLK
 | ||||
| -- clock-names: "source", "hclk"
 | ||||
| +- clocks: Should contain phandle for the clock feeding the MMC controller
 | ||||
| +- clock-names: Should contain the following:
 | ||||
| +	"source" - source clock (required)
 | ||||
| +	"hclk" - HCLK which used for host (required)
 | ||||
| +	"source_cg" - independent source clock gate (required for MT2712)
 | ||||
|  - pinctrl-names: should be "default", "state_uhs" | ||||
|  - pinctrl-0: should contain default/high speed pin ctrl | ||||
|  - pinctrl-1: should contain uhs mode pin ctrl | ||||
| @@ -30,6 +38,10 @@ Optional properties:
 | ||||
|  - mediatek,hs400-cmd-resp-sel-rising:  HS400 command response sample selection | ||||
|  				       If present,HS400 command responses are sampled on rising edges. | ||||
|  				       If not present,HS400 command responses are sampled on falling edges. | ||||
| +- mediatek,latch-ck: Some SoCs do not support enhance_rx, need set correct latch-ck to avoid data crc
 | ||||
| +		     error caused by stop clock(fifo full)
 | ||||
| +		     Valid range = [0:0x7]. if not present, default value is 0.
 | ||||
| +		     applied to compatible "mediatek,mt2701-mmc".
 | ||||
|   | ||||
|  Examples: | ||||
|  mmc0: mmc@11230000 { | ||||
|  | @ -0,0 +1,187 @@ | |||
| From 8119f3e147deaf97a66e953fecf3d2b0edbb07fd Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:29 +0800 | ||||
| Subject: [PATCH 143/224] mmc: mediatek: add support of mt2701/mt2712 | ||||
| 
 | ||||
| mt2701/mt2712 has 12bit clock div, which is not compatible with | ||||
| mt8135/mt8173. and, some additional features will be added in | ||||
| mt2701/mt2712, so that need distinguish it by comatibale name. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 82 +++++++++++++++++++++++++++++++++++++++-------- | ||||
|  1 file changed, 69 insertions(+), 13 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -95,6 +95,9 @@
 | ||||
|  #define MSDC_CFG_CKDIV          (0xff << 8)	/* RW */ | ||||
|  #define MSDC_CFG_CKMOD          (0x3 << 16)	/* RW */ | ||||
|  #define MSDC_CFG_HS400_CK_MODE  (0x1 << 18)	/* RW */ | ||||
| +#define MSDC_CFG_HS400_CK_MODE_EXTRA  (0x1 << 22)	/* RW */
 | ||||
| +#define MSDC_CFG_CKDIV_EXTRA    (0xfff << 8)	/* RW */
 | ||||
| +#define MSDC_CFG_CKMOD_EXTRA    (0x3 << 20)	/* RW */
 | ||||
|   | ||||
|  /* MSDC_IOCON mask */ | ||||
|  #define MSDC_IOCON_SDR104CKS    (0x1 << 0)	/* RW */ | ||||
| @@ -295,6 +298,10 @@ struct msdc_save_para {
 | ||||
|  	u32 emmc50_cfg0; | ||||
|  }; | ||||
|   | ||||
| +struct mtk_mmc_compatible {
 | ||||
| +	u8 clk_div_bits;
 | ||||
| +};
 | ||||
| +
 | ||||
|  struct msdc_tune_para { | ||||
|  	u32 iocon; | ||||
|  	u32 pad_tune; | ||||
| @@ -309,6 +316,7 @@ struct msdc_delay_phase {
 | ||||
|   | ||||
|  struct msdc_host { | ||||
|  	struct device *dev; | ||||
| +	const struct mtk_mmc_compatible *dev_comp;
 | ||||
|  	struct mmc_host *mmc;	/* mmc structure */ | ||||
|  	int cmd_rsp; | ||||
|   | ||||
| @@ -350,6 +358,31 @@ struct msdc_host {
 | ||||
|  	struct msdc_tune_para saved_tune_para; /* tune result of CMD21/CMD19 */ | ||||
|  }; | ||||
|   | ||||
| +static const struct mtk_mmc_compatible mt8135_compat = {
 | ||||
| +	.clk_div_bits = 8,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct mtk_mmc_compatible mt8173_compat = {
 | ||||
| +	.clk_div_bits = 8,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct mtk_mmc_compatible mt2701_compat = {
 | ||||
| +	.clk_div_bits = 12,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct mtk_mmc_compatible mt2712_compat = {
 | ||||
| +	.clk_div_bits = 12,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct of_device_id msdc_of_ids[] = {
 | ||||
| +	{ .compatible = "mediatek,mt8135-mmc", .data = &mt8135_compat},
 | ||||
| +	{ .compatible = "mediatek,mt8173-mmc", .data = &mt8173_compat},
 | ||||
| +	{ .compatible = "mediatek,mt2701-mmc", .data = &mt2701_compat},
 | ||||
| +	{ .compatible = "mediatek,mt2712-mmc", .data = &mt2712_compat},
 | ||||
| +	{}
 | ||||
| +};
 | ||||
| +MODULE_DEVICE_TABLE(of, msdc_of_ids);
 | ||||
| +
 | ||||
|  static void sdr_set_bits(void __iomem *reg, u32 bs) | ||||
|  { | ||||
|  	u32 val = readl(reg); | ||||
| @@ -509,7 +542,12 @@ static void msdc_set_timeout(struct msdc
 | ||||
|  		timeout = (ns + clk_ns - 1) / clk_ns + clks; | ||||
|  		/* in 1048576 sclk cycle unit */ | ||||
|  		timeout = (timeout + (0x1 << 20) - 1) >> 20; | ||||
| -		sdr_get_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD, &mode);
 | ||||
| +		if (host->dev_comp->clk_div_bits == 8)
 | ||||
| +			sdr_get_field(host->base + MSDC_CFG,
 | ||||
| +				      MSDC_CFG_CKMOD, &mode);
 | ||||
| +		else
 | ||||
| +			sdr_get_field(host->base + MSDC_CFG,
 | ||||
| +				      MSDC_CFG_CKMOD_EXTRA, &mode);
 | ||||
|  		/*DDR mode will double the clk cycles for data timeout */ | ||||
|  		timeout = mode >= 2 ? timeout * 2 : timeout; | ||||
|  		timeout = timeout > 1 ? timeout - 1 : 0; | ||||
| @@ -548,7 +586,11 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|   | ||||
|  	flags = readl(host->base + MSDC_INTEN); | ||||
|  	sdr_clr_bits(host->base + MSDC_INTEN, flags); | ||||
| -	sdr_clr_bits(host->base + MSDC_CFG, MSDC_CFG_HS400_CK_MODE);
 | ||||
| +	if (host->dev_comp->clk_div_bits == 8)
 | ||||
| +		sdr_clr_bits(host->base + MSDC_CFG, MSDC_CFG_HS400_CK_MODE);
 | ||||
| +	else
 | ||||
| +		sdr_clr_bits(host->base + MSDC_CFG,
 | ||||
| +			     MSDC_CFG_HS400_CK_MODE_EXTRA);
 | ||||
|  	if (timing == MMC_TIMING_UHS_DDR50 || | ||||
|  	    timing == MMC_TIMING_MMC_DDR52 || | ||||
|  	    timing == MMC_TIMING_MMC_HS400) { | ||||
| @@ -568,8 +610,12 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|   | ||||
|  		if (timing == MMC_TIMING_MMC_HS400 && | ||||
|  		    hz >= (host->src_clk_freq >> 1)) { | ||||
| -			sdr_set_bits(host->base + MSDC_CFG,
 | ||||
| -				     MSDC_CFG_HS400_CK_MODE);
 | ||||
| +			if (host->dev_comp->clk_div_bits == 8)
 | ||||
| +				sdr_set_bits(host->base + MSDC_CFG,
 | ||||
| +					     MSDC_CFG_HS400_CK_MODE);
 | ||||
| +			else
 | ||||
| +				sdr_set_bits(host->base + MSDC_CFG,
 | ||||
| +					     MSDC_CFG_HS400_CK_MODE_EXTRA);
 | ||||
|  			sclk = host->src_clk_freq >> 1; | ||||
|  			div = 0; /* div is ignore when bit18 is set */ | ||||
|  		} | ||||
| @@ -587,8 +633,15 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  			sclk = (host->src_clk_freq >> 2) / div; | ||||
|  		} | ||||
|  	} | ||||
| -	sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD | MSDC_CFG_CKDIV,
 | ||||
| -		      (mode << 8) | div);
 | ||||
| +	if (host->dev_comp->clk_div_bits == 8)
 | ||||
| +		sdr_set_field(host->base + MSDC_CFG,
 | ||||
| +			      MSDC_CFG_CKMOD | MSDC_CFG_CKDIV,
 | ||||
| +			      (mode << 8) | div);
 | ||||
| +	else
 | ||||
| +		sdr_set_field(host->base + MSDC_CFG,
 | ||||
| +			      MSDC_CFG_CKMOD_EXTRA | MSDC_CFG_CKDIV_EXTRA,
 | ||||
| +			      (mode << 12) | div);
 | ||||
| +
 | ||||
|  	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN); | ||||
|  	while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) | ||||
|  		cpu_relax(); | ||||
| @@ -1617,12 +1670,17 @@ static int msdc_drv_probe(struct platfor
 | ||||
|  	struct mmc_host *mmc; | ||||
|  	struct msdc_host *host; | ||||
|  	struct resource *res; | ||||
| +	const struct of_device_id *of_id;
 | ||||
|  	int ret; | ||||
|   | ||||
|  	if (!pdev->dev.of_node) { | ||||
|  		dev_err(&pdev->dev, "No DT found\n"); | ||||
|  		return -EINVAL; | ||||
|  	} | ||||
| +
 | ||||
| +	of_id = of_match_node(msdc_of_ids, pdev->dev.of_node);
 | ||||
| +	if (!of_id)
 | ||||
| +		return -EINVAL;
 | ||||
|  	/* Allocate MMC host for this device */ | ||||
|  	mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev); | ||||
|  	if (!mmc) | ||||
| @@ -1686,11 +1744,15 @@ static int msdc_drv_probe(struct platfor
 | ||||
|  	msdc_of_property_parse(pdev, host); | ||||
|   | ||||
|  	host->dev = &pdev->dev; | ||||
| +	host->dev_comp = of_id->data;
 | ||||
|  	host->mmc = mmc; | ||||
|  	host->src_clk_freq = clk_get_rate(host->src_clk); | ||||
|  	/* Set host parameters to mmc */ | ||||
|  	mmc->ops = &mt_msdc_ops; | ||||
| -	mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 255);
 | ||||
| +	if (host->dev_comp->clk_div_bits == 8)
 | ||||
| +		mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 255);
 | ||||
| +	else
 | ||||
| +		mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 4095);
 | ||||
|   | ||||
|  	mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; | ||||
|  	/* MMC core transfer sizes tunable parameters */ | ||||
| @@ -1839,12 +1901,6 @@ static const struct dev_pm_ops msdc_dev_
 | ||||
|  	SET_RUNTIME_PM_OPS(msdc_runtime_suspend, msdc_runtime_resume, NULL) | ||||
|  }; | ||||
|   | ||||
| -static const struct of_device_id msdc_of_ids[] = {
 | ||||
| -	{   .compatible = "mediatek,mt8135-mmc", },
 | ||||
| -	{}
 | ||||
| -};
 | ||||
| -MODULE_DEVICE_TABLE(of, msdc_of_ids);
 | ||||
| -
 | ||||
|  static struct platform_driver mt_msdc_driver = { | ||||
|  	.probe = msdc_drv_probe, | ||||
|  	.remove = msdc_drv_remove, | ||||
|  | @ -0,0 +1,196 @@ | |||
| From 815d90faddd22e05f05623086a9c42187fbfb1d8 Mon Sep 17 00:00:00 2001 | ||||
| From: "weiyi.lu@mediatek.com" <weiyi.lu@mediatek.com> | ||||
| Date: Mon, 23 Oct 2017 12:10:32 +0800 | ||||
| Subject: [PATCH 144/224] dt-bindings: ARM: Mediatek: Document bindings for | ||||
|  MT2712 | ||||
| 
 | ||||
| This patch adds the binding documentation for apmixedsys, bdpsys, | ||||
| imgsys, imgsys, infracfg, mcucfg, mfgcfg, mmsys, pericfg, topckgen, | ||||
| vdecsys and vencsys for Mediatek MT2712. | ||||
| 
 | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Weiyi Lu <weiyi.lu@mediatek.com> | ||||
| Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> | ||||
| ---
 | ||||
|  .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,bdpsys.txt      |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,imgsys.txt      |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,infracfg.txt    |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,jpgdecsys.txt   | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,mcucfg.txt      | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,mfgcfg.txt      | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,mmsys.txt       |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,pericfg.txt     |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,topckgen.txt    |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,vdecsys.txt     |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,vencsys.txt     |  1 + | ||||
|  12 files changed, 75 insertions(+) | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,jpgdecsys.txt | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mcucfg.txt | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mfgcfg.txt | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-apmixedsys" | ||||
| +	- "mediatek,mt2712-apmixedsys", "syscon"
 | ||||
|  	- "mediatek,mt6797-apmixedsys" | ||||
|  	- "mediatek,mt8135-apmixedsys" | ||||
|  	- "mediatek,mt8173-apmixedsys" | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,bdpsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,bdpsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be: | ||||
|  	- "mediatek,mt2701-bdpsys", "syscon" | ||||
| +	- "mediatek,mt2712-bdpsys", "syscon"
 | ||||
|  - #clock-cells: Must be 1 | ||||
|   | ||||
|  The bdpsys controller uses the common clk binding from | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-imgsys", "syscon" | ||||
| +	- "mediatek,mt2712-imgsys", "syscon"
 | ||||
|  	- "mediatek,mt6797-imgsys", "syscon" | ||||
|  	- "mediatek,mt8173-imgsys", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | ||||
| @@ -8,6 +8,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-infracfg", "syscon" | ||||
| +	- "mediatek,mt2712-infracfg", "syscon"
 | ||||
|  	- "mediatek,mt6797-infracfg", "syscon" | ||||
|  	- "mediatek,mt8135-infracfg", "syscon" | ||||
|  	- "mediatek,mt8173-infracfg", "syscon" | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,jpgdecsys.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +Mediatek jpgdecsys controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The Mediatek jpgdecsys controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be:
 | ||||
| +	- "mediatek,mt2712-jpgdecsys", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The jpgdecsys controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +jpgdecsys: syscon@19000000 {
 | ||||
| +	compatible = "mediatek,mt2712-jpgdecsys", "syscon";
 | ||||
| +	reg = <0 0x19000000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mcucfg.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +Mediatek mcucfg controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The Mediatek mcucfg controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be one of:
 | ||||
| +	- "mediatek,mt2712-mcucfg", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The mcucfg controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +mcucfg: syscon@10220000 {
 | ||||
| +	compatible = "mediatek,mt2712-mcucfg", "syscon";
 | ||||
| +	reg = <0 0x10220000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mfgcfg.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +Mediatek mfgcfg controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The Mediatek mfgcfg controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be one of:
 | ||||
| +	- "mediatek,mt2712-mfgcfg", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The mfgcfg controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +mfgcfg: syscon@13000000 {
 | ||||
| +	compatible = "mediatek,mt2712-mfgcfg", "syscon";
 | ||||
| +	reg = <0 0x13000000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-mmsys", "syscon" | ||||
| +	- "mediatek,mt2712-mmsys", "syscon"
 | ||||
|  	- "mediatek,mt6797-mmsys", "syscon" | ||||
|  	- "mediatek,mt8173-mmsys", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | ||||
| @@ -8,6 +8,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-pericfg", "syscon" | ||||
| +	- "mediatek,mt2712-pericfg", "syscon"
 | ||||
|  	- "mediatek,mt8135-pericfg", "syscon" | ||||
|  	- "mediatek,mt8173-pericfg", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-topckgen" | ||||
| +	- "mediatek,mt2712-topckgen", "syscon"
 | ||||
|  	- "mediatek,mt6797-topckgen" | ||||
|  	- "mediatek,mt8135-topckgen" | ||||
|  	- "mediatek,mt8173-topckgen" | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,vdecsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,vdecsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-vdecsys", "syscon" | ||||
| +	- "mediatek,mt2712-vdecsys", "syscon"
 | ||||
|  	- "mediatek,mt6797-vdecsys", "syscon" | ||||
|  	- "mediatek,mt8173-vdecsys", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,vencsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,vencsys.txt
 | ||||
| @@ -6,6 +6,7 @@ The Mediatek vencsys controller provides
 | ||||
|  Required Properties: | ||||
|   | ||||
|  - compatible: Should be one of: | ||||
| +	- "mediatek,mt2712-vencsys", "syscon"
 | ||||
|  	- "mediatek,mt6797-vencsys", "syscon" | ||||
|  	- "mediatek,mt8173-vencsys", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
|  | @ -0,0 +1,446 @@ | |||
| From 8a64bf0c04a4b7670cf56be5b0ae63fe9d6ecd56 Mon Sep 17 00:00:00 2001 | ||||
| From: "weiyi.lu@mediatek.com" <weiyi.lu@mediatek.com> | ||||
| Date: Mon, 23 Oct 2017 12:10:33 +0800 | ||||
| Subject: [PATCH 145/224] clk: mediatek: Add dt-bindings for MT2712 clocks | ||||
| 
 | ||||
| Add MT2712 clock dt-bindings, include topckgen, apmixedsys, | ||||
| infracfg, pericfg, mcucfg and subsystem clocks. | ||||
| 
 | ||||
| Signed-off-by: Weiyi Lu <weiyi.lu@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> | ||||
| ---
 | ||||
|  include/dt-bindings/clock/mt2712-clk.h | 427 +++++++++++++++++++++++++++++++++ | ||||
|  1 file changed, 427 insertions(+) | ||||
|  create mode 100644 include/dt-bindings/clock/mt2712-clk.h | ||||
| 
 | ||||
| --- /dev/null
 | ||||
| +++ b/include/dt-bindings/clock/mt2712-clk.h
 | ||||
| @@ -0,0 +1,427 @@
 | ||||
| +/*
 | ||||
| + * Copyright (c) 2017 MediaTek Inc.
 | ||||
| + * Author: Weiyi Lu <weiyi.lu@mediatek.com>
 | ||||
| + *
 | ||||
| + * This program is free software; you can redistribute it and/or modify
 | ||||
| + * it under the terms of the GNU General Public License version 2 as
 | ||||
| + * published by the Free Software Foundation.
 | ||||
| + *
 | ||||
| + * 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.
 | ||||
| + */
 | ||||
| +
 | ||||
| +#ifndef _DT_BINDINGS_CLK_MT2712_H
 | ||||
| +#define _DT_BINDINGS_CLK_MT2712_H
 | ||||
| +
 | ||||
| +/* APMIXEDSYS */
 | ||||
| +
 | ||||
| +#define CLK_APMIXED_MAINPLL		0
 | ||||
| +#define CLK_APMIXED_UNIVPLL		1
 | ||||
| +#define CLK_APMIXED_VCODECPLL		2
 | ||||
| +#define CLK_APMIXED_VENCPLL		3
 | ||||
| +#define CLK_APMIXED_APLL1		4
 | ||||
| +#define CLK_APMIXED_APLL2		5
 | ||||
| +#define CLK_APMIXED_LVDSPLL		6
 | ||||
| +#define CLK_APMIXED_LVDSPLL2		7
 | ||||
| +#define CLK_APMIXED_MSDCPLL		8
 | ||||
| +#define CLK_APMIXED_MSDCPLL2		9
 | ||||
| +#define CLK_APMIXED_TVDPLL		10
 | ||||
| +#define CLK_APMIXED_MMPLL		11
 | ||||
| +#define CLK_APMIXED_ARMCA35PLL		12
 | ||||
| +#define CLK_APMIXED_ARMCA72PLL		13
 | ||||
| +#define CLK_APMIXED_ETHERPLL		14
 | ||||
| +#define CLK_APMIXED_NR_CLK		15
 | ||||
| +
 | ||||
| +/* TOPCKGEN */
 | ||||
| +
 | ||||
| +#define CLK_TOP_ARMCA35PLL		0
 | ||||
| +#define CLK_TOP_ARMCA35PLL_600M		1
 | ||||
| +#define CLK_TOP_ARMCA35PLL_400M		2
 | ||||
| +#define CLK_TOP_ARMCA72PLL		3
 | ||||
| +#define CLK_TOP_SYSPLL			4
 | ||||
| +#define CLK_TOP_SYSPLL_D2		5
 | ||||
| +#define CLK_TOP_SYSPLL1_D2		6
 | ||||
| +#define CLK_TOP_SYSPLL1_D4		7
 | ||||
| +#define CLK_TOP_SYSPLL1_D8		8
 | ||||
| +#define CLK_TOP_SYSPLL1_D16		9
 | ||||
| +#define CLK_TOP_SYSPLL_D3		10
 | ||||
| +#define CLK_TOP_SYSPLL2_D2		11
 | ||||
| +#define CLK_TOP_SYSPLL2_D4		12
 | ||||
| +#define CLK_TOP_SYSPLL_D5		13
 | ||||
| +#define CLK_TOP_SYSPLL3_D2		14
 | ||||
| +#define CLK_TOP_SYSPLL3_D4		15
 | ||||
| +#define CLK_TOP_SYSPLL_D7		16
 | ||||
| +#define CLK_TOP_SYSPLL4_D2		17
 | ||||
| +#define CLK_TOP_SYSPLL4_D4		18
 | ||||
| +#define CLK_TOP_UNIVPLL			19
 | ||||
| +#define CLK_TOP_UNIVPLL_D7		20
 | ||||
| +#define CLK_TOP_UNIVPLL_D26		21
 | ||||
| +#define CLK_TOP_UNIVPLL_D52		22
 | ||||
| +#define CLK_TOP_UNIVPLL_D104		23
 | ||||
| +#define CLK_TOP_UNIVPLL_D208		24
 | ||||
| +#define CLK_TOP_UNIVPLL_D2		25
 | ||||
| +#define CLK_TOP_UNIVPLL1_D2		26
 | ||||
| +#define CLK_TOP_UNIVPLL1_D4		27
 | ||||
| +#define CLK_TOP_UNIVPLL1_D8		28
 | ||||
| +#define CLK_TOP_UNIVPLL_D3		29
 | ||||
| +#define CLK_TOP_UNIVPLL2_D2		30
 | ||||
| +#define CLK_TOP_UNIVPLL2_D4		31
 | ||||
| +#define CLK_TOP_UNIVPLL2_D8		32
 | ||||
| +#define CLK_TOP_UNIVPLL_D5		33
 | ||||
| +#define CLK_TOP_UNIVPLL3_D2		34
 | ||||
| +#define CLK_TOP_UNIVPLL3_D4		35
 | ||||
| +#define CLK_TOP_UNIVPLL3_D8		36
 | ||||
| +#define CLK_TOP_F_MP0_PLL1		37
 | ||||
| +#define CLK_TOP_F_MP0_PLL2		38
 | ||||
| +#define CLK_TOP_F_BIG_PLL1		39
 | ||||
| +#define CLK_TOP_F_BIG_PLL2		40
 | ||||
| +#define CLK_TOP_F_BUS_PLL1		41
 | ||||
| +#define CLK_TOP_F_BUS_PLL2		42
 | ||||
| +#define CLK_TOP_APLL1			43
 | ||||
| +#define CLK_TOP_APLL1_D2		44
 | ||||
| +#define CLK_TOP_APLL1_D4		45
 | ||||
| +#define CLK_TOP_APLL1_D8		46
 | ||||
| +#define CLK_TOP_APLL1_D16		47
 | ||||
| +#define CLK_TOP_APLL2			48
 | ||||
| +#define CLK_TOP_APLL2_D2		49
 | ||||
| +#define CLK_TOP_APLL2_D4		50
 | ||||
| +#define CLK_TOP_APLL2_D8		51
 | ||||
| +#define CLK_TOP_APLL2_D16		52
 | ||||
| +#define CLK_TOP_LVDSPLL			53
 | ||||
| +#define CLK_TOP_LVDSPLL_D2		54
 | ||||
| +#define CLK_TOP_LVDSPLL_D4		55
 | ||||
| +#define CLK_TOP_LVDSPLL_D8		56
 | ||||
| +#define CLK_TOP_LVDSPLL2		57
 | ||||
| +#define CLK_TOP_LVDSPLL2_D2		58
 | ||||
| +#define CLK_TOP_LVDSPLL2_D4		59
 | ||||
| +#define CLK_TOP_LVDSPLL2_D8		60
 | ||||
| +#define CLK_TOP_ETHERPLL_125M		61
 | ||||
| +#define CLK_TOP_ETHERPLL_50M		62
 | ||||
| +#define CLK_TOP_CVBS			63
 | ||||
| +#define CLK_TOP_CVBS_D2			64
 | ||||
| +#define CLK_TOP_SYS_26M			65
 | ||||
| +#define CLK_TOP_MMPLL			66
 | ||||
| +#define CLK_TOP_MMPLL_D2		67
 | ||||
| +#define CLK_TOP_VENCPLL			68
 | ||||
| +#define CLK_TOP_VENCPLL_D2		69
 | ||||
| +#define CLK_TOP_VCODECPLL		70
 | ||||
| +#define CLK_TOP_VCODECPLL_D2		71
 | ||||
| +#define CLK_TOP_TVDPLL			72
 | ||||
| +#define CLK_TOP_TVDPLL_D2		73
 | ||||
| +#define CLK_TOP_TVDPLL_D4		74
 | ||||
| +#define CLK_TOP_TVDPLL_D8		75
 | ||||
| +#define CLK_TOP_TVDPLL_429M		76
 | ||||
| +#define CLK_TOP_TVDPLL_429M_D2		77
 | ||||
| +#define CLK_TOP_TVDPLL_429M_D4		78
 | ||||
| +#define CLK_TOP_MSDCPLL			79
 | ||||
| +#define CLK_TOP_MSDCPLL_D2		80
 | ||||
| +#define CLK_TOP_MSDCPLL_D4		81
 | ||||
| +#define CLK_TOP_MSDCPLL2		82
 | ||||
| +#define CLK_TOP_MSDCPLL2_D2		83
 | ||||
| +#define CLK_TOP_MSDCPLL2_D4		84
 | ||||
| +#define CLK_TOP_CLK26M_D2		85
 | ||||
| +#define CLK_TOP_D2A_ULCLK_6P5M		86
 | ||||
| +#define CLK_TOP_VPLL3_DPIX		87
 | ||||
| +#define CLK_TOP_VPLL_DPIX		88
 | ||||
| +#define CLK_TOP_LTEPLL_FS26M		89
 | ||||
| +#define CLK_TOP_DMPLL			90
 | ||||
| +#define CLK_TOP_DSI0_LNTC		91
 | ||||
| +#define CLK_TOP_DSI1_LNTC		92
 | ||||
| +#define CLK_TOP_LVDSTX3_CLKDIG_CTS	93
 | ||||
| +#define CLK_TOP_LVDSTX_CLKDIG_CTS	94
 | ||||
| +#define CLK_TOP_CLKRTC_EXT		95
 | ||||
| +#define CLK_TOP_CLKRTC_INT		96
 | ||||
| +#define CLK_TOP_CSI0			97
 | ||||
| +#define CLK_TOP_CVBSPLL			98
 | ||||
| +#define CLK_TOP_AXI_SEL			99
 | ||||
| +#define CLK_TOP_MEM_SEL			100
 | ||||
| +#define CLK_TOP_MM_SEL			101
 | ||||
| +#define CLK_TOP_PWM_SEL			102
 | ||||
| +#define CLK_TOP_VDEC_SEL		103
 | ||||
| +#define CLK_TOP_VENC_SEL		104
 | ||||
| +#define CLK_TOP_MFG_SEL			105
 | ||||
| +#define CLK_TOP_CAMTG_SEL		106
 | ||||
| +#define CLK_TOP_UART_SEL		107
 | ||||
| +#define CLK_TOP_SPI_SEL			108
 | ||||
| +#define CLK_TOP_USB20_SEL		109
 | ||||
| +#define CLK_TOP_USB30_SEL		110
 | ||||
| +#define CLK_TOP_MSDC50_0_HCLK_SEL	111
 | ||||
| +#define CLK_TOP_MSDC50_0_SEL		112
 | ||||
| +#define CLK_TOP_MSDC30_1_SEL		113
 | ||||
| +#define CLK_TOP_MSDC30_2_SEL		114
 | ||||
| +#define CLK_TOP_MSDC30_3_SEL		115
 | ||||
| +#define CLK_TOP_AUDIO_SEL		116
 | ||||
| +#define CLK_TOP_AUD_INTBUS_SEL		117
 | ||||
| +#define CLK_TOP_PMICSPI_SEL		118
 | ||||
| +#define CLK_TOP_DPILVDS1_SEL		119
 | ||||
| +#define CLK_TOP_ATB_SEL			120
 | ||||
| +#define CLK_TOP_NR_SEL			121
 | ||||
| +#define CLK_TOP_NFI2X_SEL		122
 | ||||
| +#define CLK_TOP_IRDA_SEL		123
 | ||||
| +#define CLK_TOP_CCI400_SEL		124
 | ||||
| +#define CLK_TOP_AUD_1_SEL		125
 | ||||
| +#define CLK_TOP_AUD_2_SEL		126
 | ||||
| +#define CLK_TOP_MEM_MFG_IN_AS_SEL	127
 | ||||
| +#define CLK_TOP_AXI_MFG_IN_AS_SEL	128
 | ||||
| +#define CLK_TOP_SCAM_SEL		129
 | ||||
| +#define CLK_TOP_NFIECC_SEL		130
 | ||||
| +#define CLK_TOP_PE2_MAC_P0_SEL		131
 | ||||
| +#define CLK_TOP_PE2_MAC_P1_SEL		132
 | ||||
| +#define CLK_TOP_DPILVDS_SEL		133
 | ||||
| +#define CLK_TOP_MSDC50_3_HCLK_SEL	134
 | ||||
| +#define CLK_TOP_HDCP_SEL		135
 | ||||
| +#define CLK_TOP_HDCP_24M_SEL		136
 | ||||
| +#define CLK_TOP_RTC_SEL			137
 | ||||
| +#define CLK_TOP_SPINOR_SEL		138
 | ||||
| +#define CLK_TOP_APLL_SEL		139
 | ||||
| +#define CLK_TOP_APLL2_SEL		140
 | ||||
| +#define CLK_TOP_A1SYS_HP_SEL		141
 | ||||
| +#define CLK_TOP_A2SYS_HP_SEL		142
 | ||||
| +#define CLK_TOP_ASM_L_SEL		143
 | ||||
| +#define CLK_TOP_ASM_M_SEL		144
 | ||||
| +#define CLK_TOP_ASM_H_SEL		145
 | ||||
| +#define CLK_TOP_I2SO1_SEL		146
 | ||||
| +#define CLK_TOP_I2SO2_SEL		147
 | ||||
| +#define CLK_TOP_I2SO3_SEL		148
 | ||||
| +#define CLK_TOP_TDMO0_SEL		149
 | ||||
| +#define CLK_TOP_TDMO1_SEL		150
 | ||||
| +#define CLK_TOP_I2SI1_SEL		151
 | ||||
| +#define CLK_TOP_I2SI2_SEL		152
 | ||||
| +#define CLK_TOP_I2SI3_SEL		153
 | ||||
| +#define CLK_TOP_ETHER_125M_SEL		154
 | ||||
| +#define CLK_TOP_ETHER_50M_SEL		155
 | ||||
| +#define CLK_TOP_JPGDEC_SEL		156
 | ||||
| +#define CLK_TOP_SPISLV_SEL		157
 | ||||
| +#define CLK_TOP_ETHER_50M_RMII_SEL	158
 | ||||
| +#define CLK_TOP_CAM2TG_SEL		159
 | ||||
| +#define CLK_TOP_DI_SEL			160
 | ||||
| +#define CLK_TOP_TVD_SEL			161
 | ||||
| +#define CLK_TOP_I2C_SEL			162
 | ||||
| +#define CLK_TOP_PWM_INFRA_SEL		163
 | ||||
| +#define CLK_TOP_MSDC0P_AES_SEL		164
 | ||||
| +#define CLK_TOP_CMSYS_SEL		165
 | ||||
| +#define CLK_TOP_GCPU_SEL		166
 | ||||
| +#define CLK_TOP_AUD_APLL1_SEL		167
 | ||||
| +#define CLK_TOP_AUD_APLL2_SEL		168
 | ||||
| +#define CLK_TOP_DA_AUDULL_VTX_6P5M_SEL	169
 | ||||
| +#define CLK_TOP_APLL_DIV0		170
 | ||||
| +#define CLK_TOP_APLL_DIV1		171
 | ||||
| +#define CLK_TOP_APLL_DIV2		172
 | ||||
| +#define CLK_TOP_APLL_DIV3		173
 | ||||
| +#define CLK_TOP_APLL_DIV4		174
 | ||||
| +#define CLK_TOP_APLL_DIV5		175
 | ||||
| +#define CLK_TOP_APLL_DIV6		176
 | ||||
| +#define CLK_TOP_APLL_DIV7		177
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN0		178
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN1		179
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN2		180
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN3		181
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN4		182
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN5		183
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN6		184
 | ||||
| +#define CLK_TOP_APLL_DIV_PDN7		185
 | ||||
| +#define CLK_TOP_NR_CLK			186
 | ||||
| +
 | ||||
| +/* INFRACFG */
 | ||||
| +
 | ||||
| +#define CLK_INFRA_DBGCLK		0
 | ||||
| +#define CLK_INFRA_GCE			1
 | ||||
| +#define CLK_INFRA_M4U			2
 | ||||
| +#define CLK_INFRA_KP			3
 | ||||
| +#define CLK_INFRA_AO_SPI0		4
 | ||||
| +#define CLK_INFRA_AO_SPI1		5
 | ||||
| +#define CLK_INFRA_AO_UART5		6
 | ||||
| +#define CLK_INFRA_NR_CLK		7
 | ||||
| +
 | ||||
| +/* PERICFG */
 | ||||
| +
 | ||||
| +#define CLK_PERI_NFI			0
 | ||||
| +#define CLK_PERI_THERM			1
 | ||||
| +#define CLK_PERI_PWM0			2
 | ||||
| +#define CLK_PERI_PWM1			3
 | ||||
| +#define CLK_PERI_PWM2			4
 | ||||
| +#define CLK_PERI_PWM3			5
 | ||||
| +#define CLK_PERI_PWM4			6
 | ||||
| +#define CLK_PERI_PWM5			7
 | ||||
| +#define CLK_PERI_PWM6			8
 | ||||
| +#define CLK_PERI_PWM7			9
 | ||||
| +#define CLK_PERI_PWM			10
 | ||||
| +#define CLK_PERI_AP_DMA			11
 | ||||
| +#define CLK_PERI_MSDC30_0		12
 | ||||
| +#define CLK_PERI_MSDC30_1		13
 | ||||
| +#define CLK_PERI_MSDC30_2		14
 | ||||
| +#define CLK_PERI_MSDC30_3		15
 | ||||
| +#define CLK_PERI_UART0			16
 | ||||
| +#define CLK_PERI_UART1			17
 | ||||
| +#define CLK_PERI_UART2			18
 | ||||
| +#define CLK_PERI_UART3			19
 | ||||
| +#define CLK_PERI_I2C0			20
 | ||||
| +#define CLK_PERI_I2C1			21
 | ||||
| +#define CLK_PERI_I2C2			22
 | ||||
| +#define CLK_PERI_I2C3			23
 | ||||
| +#define CLK_PERI_I2C4			24
 | ||||
| +#define CLK_PERI_AUXADC			25
 | ||||
| +#define CLK_PERI_SPI0			26
 | ||||
| +#define CLK_PERI_SPI			27
 | ||||
| +#define CLK_PERI_I2C5			28
 | ||||
| +#define CLK_PERI_SPI2			29
 | ||||
| +#define CLK_PERI_SPI3			30
 | ||||
| +#define CLK_PERI_SPI5			31
 | ||||
| +#define CLK_PERI_UART4			32
 | ||||
| +#define CLK_PERI_SFLASH			33
 | ||||
| +#define CLK_PERI_GMAC			34
 | ||||
| +#define CLK_PERI_PCIE0			35
 | ||||
| +#define CLK_PERI_PCIE1			36
 | ||||
| +#define CLK_PERI_GMAC_PCLK		37
 | ||||
| +#define CLK_PERI_MSDC50_0_EN		38
 | ||||
| +#define CLK_PERI_MSDC30_1_EN		39
 | ||||
| +#define CLK_PERI_MSDC30_2_EN		40
 | ||||
| +#define CLK_PERI_MSDC30_3_EN		41
 | ||||
| +#define CLK_PERI_MSDC50_0_HCLK_EN	42
 | ||||
| +#define CLK_PERI_MSDC50_3_HCLK_EN	43
 | ||||
| +#define CLK_PERI_NR_CLK			44
 | ||||
| +
 | ||||
| +/* MCUCFG */
 | ||||
| +
 | ||||
| +#define CLK_MCU_MP0_SEL			0
 | ||||
| +#define CLK_MCU_MP2_SEL			1
 | ||||
| +#define CLK_MCU_BUS_SEL			2
 | ||||
| +#define CLK_MCU_NR_CLK			3
 | ||||
| +
 | ||||
| +/* MFGCFG */
 | ||||
| +
 | ||||
| +#define CLK_MFG_BG3D			0
 | ||||
| +#define CLK_MFG_NR_CLK			1
 | ||||
| +
 | ||||
| +/* MMSYS */
 | ||||
| +
 | ||||
| +#define CLK_MM_SMI_COMMON		0
 | ||||
| +#define CLK_MM_SMI_LARB0		1
 | ||||
| +#define CLK_MM_CAM_MDP			2
 | ||||
| +#define CLK_MM_MDP_RDMA0		3
 | ||||
| +#define CLK_MM_MDP_RDMA1		4
 | ||||
| +#define CLK_MM_MDP_RSZ0			5
 | ||||
| +#define CLK_MM_MDP_RSZ1			6
 | ||||
| +#define CLK_MM_MDP_RSZ2			7
 | ||||
| +#define CLK_MM_MDP_TDSHP0		8
 | ||||
| +#define CLK_MM_MDP_TDSHP1		9
 | ||||
| +#define CLK_MM_MDP_CROP			10
 | ||||
| +#define CLK_MM_MDP_WDMA			11
 | ||||
| +#define CLK_MM_MDP_WROT0		12
 | ||||
| +#define CLK_MM_MDP_WROT1		13
 | ||||
| +#define CLK_MM_FAKE_ENG			14
 | ||||
| +#define CLK_MM_MUTEX_32K		15
 | ||||
| +#define CLK_MM_DISP_OVL0		16
 | ||||
| +#define CLK_MM_DISP_OVL1		17
 | ||||
| +#define CLK_MM_DISP_RDMA0		18
 | ||||
| +#define CLK_MM_DISP_RDMA1		19
 | ||||
| +#define CLK_MM_DISP_RDMA2		20
 | ||||
| +#define CLK_MM_DISP_WDMA0		21
 | ||||
| +#define CLK_MM_DISP_WDMA1		22
 | ||||
| +#define CLK_MM_DISP_COLOR0		23
 | ||||
| +#define CLK_MM_DISP_COLOR1		24
 | ||||
| +#define CLK_MM_DISP_AAL			25
 | ||||
| +#define CLK_MM_DISP_GAMMA		26
 | ||||
| +#define CLK_MM_DISP_UFOE		27
 | ||||
| +#define CLK_MM_DISP_SPLIT0		28
 | ||||
| +#define CLK_MM_DISP_OD			29
 | ||||
| +#define CLK_MM_DISP_PWM0_MM		30
 | ||||
| +#define CLK_MM_DISP_PWM0_26M		31
 | ||||
| +#define CLK_MM_DISP_PWM1_MM		32
 | ||||
| +#define CLK_MM_DISP_PWM1_26M		33
 | ||||
| +#define CLK_MM_DSI0_ENGINE		34
 | ||||
| +#define CLK_MM_DSI0_DIGITAL		35
 | ||||
| +#define CLK_MM_DSI1_ENGINE		36
 | ||||
| +#define CLK_MM_DSI1_DIGITAL		37
 | ||||
| +#define CLK_MM_DPI_PIXEL		38
 | ||||
| +#define CLK_MM_DPI_ENGINE		39
 | ||||
| +#define CLK_MM_DPI1_PIXEL		40
 | ||||
| +#define CLK_MM_DPI1_ENGINE		41
 | ||||
| +#define CLK_MM_LVDS_PIXEL		42
 | ||||
| +#define CLK_MM_LVDS_CTS			43
 | ||||
| +#define CLK_MM_SMI_LARB4		44
 | ||||
| +#define CLK_MM_SMI_COMMON1		45
 | ||||
| +#define CLK_MM_SMI_LARB5		46
 | ||||
| +#define CLK_MM_MDP_RDMA2		47
 | ||||
| +#define CLK_MM_MDP_TDSHP2		48
 | ||||
| +#define CLK_MM_DISP_OVL2		49
 | ||||
| +#define CLK_MM_DISP_WDMA2		50
 | ||||
| +#define CLK_MM_DISP_COLOR2		51
 | ||||
| +#define CLK_MM_DISP_AAL1		52
 | ||||
| +#define CLK_MM_DISP_OD1			53
 | ||||
| +#define CLK_MM_LVDS1_PIXEL		54
 | ||||
| +#define CLK_MM_LVDS1_CTS		55
 | ||||
| +#define CLK_MM_SMI_LARB7		56
 | ||||
| +#define CLK_MM_MDP_RDMA3		57
 | ||||
| +#define CLK_MM_MDP_WROT2		58
 | ||||
| +#define CLK_MM_DSI2			59
 | ||||
| +#define CLK_MM_DSI2_DIGITAL		60
 | ||||
| +#define CLK_MM_DSI3			61
 | ||||
| +#define CLK_MM_DSI3_DIGITAL		62
 | ||||
| +#define CLK_MM_NR_CLK			63
 | ||||
| +
 | ||||
| +/* IMGSYS */
 | ||||
| +
 | ||||
| +#define CLK_IMG_SMI_LARB2		0
 | ||||
| +#define CLK_IMG_SENINF_SCAM_EN		1
 | ||||
| +#define CLK_IMG_SENINF_CAM_EN		2
 | ||||
| +#define CLK_IMG_CAM_SV_EN		3
 | ||||
| +#define CLK_IMG_CAM_SV1_EN		4
 | ||||
| +#define CLK_IMG_CAM_SV2_EN		5
 | ||||
| +#define CLK_IMG_NR_CLK			6
 | ||||
| +
 | ||||
| +/* BDPSYS */
 | ||||
| +
 | ||||
| +#define CLK_BDP_BRIDGE_B		0
 | ||||
| +#define CLK_BDP_BRIDGE_DRAM		1
 | ||||
| +#define CLK_BDP_LARB_DRAM		2
 | ||||
| +#define CLK_BDP_WR_CHANNEL_VDI_PXL	3
 | ||||
| +#define CLK_BDP_WR_CHANNEL_VDI_DRAM	4
 | ||||
| +#define CLK_BDP_WR_CHANNEL_VDI_B	5
 | ||||
| +#define CLK_BDP_MT_B			6
 | ||||
| +#define CLK_BDP_DISPFMT_27M		7
 | ||||
| +#define CLK_BDP_DISPFMT_27M_VDOUT	8
 | ||||
| +#define CLK_BDP_DISPFMT_27_74_74	9
 | ||||
| +#define CLK_BDP_DISPFMT_2FS		10
 | ||||
| +#define CLK_BDP_DISPFMT_2FS_2FS74_148	11
 | ||||
| +#define CLK_BDP_DISPFMT_B		12
 | ||||
| +#define CLK_BDP_VDO_DRAM		13
 | ||||
| +#define CLK_BDP_VDO_2FS			14
 | ||||
| +#define CLK_BDP_VDO_B			15
 | ||||
| +#define CLK_BDP_WR_CHANNEL_DI_PXL	16
 | ||||
| +#define CLK_BDP_WR_CHANNEL_DI_DRAM	17
 | ||||
| +#define CLK_BDP_WR_CHANNEL_DI_B		18
 | ||||
| +#define CLK_BDP_NR_AGENT		19
 | ||||
| +#define CLK_BDP_NR_DRAM			20
 | ||||
| +#define CLK_BDP_NR_B			21
 | ||||
| +#define CLK_BDP_BRIDGE_RT_B		22
 | ||||
| +#define CLK_BDP_BRIDGE_RT_DRAM		23
 | ||||
| +#define CLK_BDP_LARB_RT_DRAM		24
 | ||||
| +#define CLK_BDP_TVD_TDC			25
 | ||||
| +#define CLK_BDP_TVD_54			26
 | ||||
| +#define CLK_BDP_TVD_CBUS		27
 | ||||
| +#define CLK_BDP_NR_CLK			28
 | ||||
| +
 | ||||
| +/* VDECSYS */
 | ||||
| +
 | ||||
| +#define CLK_VDEC_CKEN			0
 | ||||
| +#define CLK_VDEC_LARB1_CKEN		1
 | ||||
| +#define CLK_VDEC_IMGRZ_CKEN		2
 | ||||
| +#define CLK_VDEC_NR_CLK			3
 | ||||
| +
 | ||||
| +/* VENCSYS */
 | ||||
| +
 | ||||
| +#define CLK_VENC_SMI_COMMON_CON		0
 | ||||
| +#define CLK_VENC_VENC			1
 | ||||
| +#define CLK_VENC_SMI_LARB6		2
 | ||||
| +#define CLK_VENC_NR_CLK			3
 | ||||
| +
 | ||||
| +/* JPGDECSYS */
 | ||||
| +
 | ||||
| +#define CLK_JPGDEC_JPGDEC1		0
 | ||||
| +#define CLK_JPGDEC_JPGDEC		1
 | ||||
| +#define CLK_JPGDEC_NR_CLK		2
 | ||||
| +
 | ||||
| +#endif /* _DT_BINDINGS_CLK_MT2712_H */
 | ||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -0,0 +1,190 @@ | |||
| From acfa4eba7a4391d443b33a3d90a07eae0ef2ebca Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Thu, 5 Oct 2017 11:50:22 +0800 | ||||
| Subject: [PATCH 147/224] dt-bindings: clock: mediatek: document clk bindings | ||||
|  for MediaTek MT7622 SoC | ||||
| 
 | ||||
| This patch adds the binding documentation for apmixedsys, ethsys, hifsys, | ||||
| infracfg, pericfg, topckgen and audsys for MT7622. | ||||
| 
 | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> | ||||
| ---
 | ||||
|  .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,audsys.txt      | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,ethsys.txt      |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,hifsys.txt      |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,infracfg.txt    |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,pciesys.txt     | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,pericfg.txt     |  1 + | ||||
|  .../bindings/arm/mediatek/mediatek,sgmiisys.txt    | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,ssusbsys.txt    | 22 ++++++++++++++++++++++ | ||||
|  .../bindings/arm/mediatek/mediatek,topckgen.txt    |  1 + | ||||
|  10 files changed, 94 insertions(+) | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,pciesys.txt | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt | ||||
|  create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,ssusbsys.txt | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | ||||
| @@ -9,6 +9,7 @@ Required Properties:
 | ||||
|  	- "mediatek,mt2701-apmixedsys" | ||||
|  	- "mediatek,mt2712-apmixedsys", "syscon" | ||||
|  	- "mediatek,mt6797-apmixedsys" | ||||
| +	- "mediatek,mt7622-apmixedsys"
 | ||||
|  	- "mediatek,mt8135-apmixedsys" | ||||
|  	- "mediatek,mt8173-apmixedsys" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +MediaTek AUDSYS controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The MediaTek AUDSYS controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be one of:
 | ||||
| +	- "mediatek,mt7622-audsys", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The AUDSYS controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +audsys: audsys@11220000 {
 | ||||
| +	compatible = "mediatek,mt7622-audsys", "syscon";
 | ||||
| +	reg = <0 0x11220000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt
 | ||||
| @@ -7,6 +7,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be: | ||||
|  	- "mediatek,mt2701-ethsys", "syscon" | ||||
| +	- "mediatek,mt7622-ethsys", "syscon"
 | ||||
|  - #clock-cells: Must be 1 | ||||
|   | ||||
|  The ethsys controller uses the common clk binding from | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,hifsys.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,hifsys.txt
 | ||||
| @@ -8,6 +8,7 @@ Required Properties:
 | ||||
|   | ||||
|  - compatible: Should be: | ||||
|  	- "mediatek,mt2701-hifsys", "syscon" | ||||
| +	- "mediatek,mt7622-hifsys", "syscon"
 | ||||
|  - #clock-cells: Must be 1 | ||||
|   | ||||
|  The hifsys controller uses the common clk binding from | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | ||||
| @@ -10,6 +10,7 @@ Required Properties:
 | ||||
|  	- "mediatek,mt2701-infracfg", "syscon" | ||||
|  	- "mediatek,mt2712-infracfg", "syscon" | ||||
|  	- "mediatek,mt6797-infracfg", "syscon" | ||||
| +	- "mediatek,mt7622-infracfg", "syscon"
 | ||||
|  	- "mediatek,mt8135-infracfg", "syscon" | ||||
|  	- "mediatek,mt8173-infracfg", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pciesys.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +MediaTek PCIESYS controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The MediaTek PCIESYS controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be:
 | ||||
| +	- "mediatek,mt7622-pciesys", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The PCIESYS controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +pciesys: pciesys@1a100800 {
 | ||||
| +	compatible = "mediatek,mt7622-pciesys", "syscon";
 | ||||
| +	reg = <0 0x1a100800 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | ||||
| @@ -9,6 +9,7 @@ Required Properties:
 | ||||
|  - compatible: Should be one of: | ||||
|  	- "mediatek,mt2701-pericfg", "syscon" | ||||
|  	- "mediatek,mt2712-pericfg", "syscon" | ||||
| +	- "mediatek,mt7622-pericfg", "syscon"
 | ||||
|  	- "mediatek,mt8135-pericfg", "syscon" | ||||
|  	- "mediatek,mt8173-pericfg", "syscon" | ||||
|  - #clock-cells: Must be 1 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +MediaTek SGMIISYS controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The MediaTek SGMIISYS controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be:
 | ||||
| +	- "mediatek,mt7622-sgmiisys", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The SGMIISYS controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +sgmiisys: sgmiisys@1b128000 {
 | ||||
| +	compatible = "mediatek,mt7622-sgmiisys", "syscon";
 | ||||
| +	reg = <0 0x1b128000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ssusbsys.txt
 | ||||
| @@ -0,0 +1,22 @@
 | ||||
| +MediaTek SSUSBSYS controller
 | ||||
| +============================
 | ||||
| +
 | ||||
| +The MediaTek SSUSBSYS controller provides various clocks to the system.
 | ||||
| +
 | ||||
| +Required Properties:
 | ||||
| +
 | ||||
| +- compatible: Should be:
 | ||||
| +	- "mediatek,mt7622-ssusbsys", "syscon"
 | ||||
| +- #clock-cells: Must be 1
 | ||||
| +
 | ||||
| +The SSUSBSYS controller uses the common clk binding from
 | ||||
| +Documentation/devicetree/bindings/clock/clock-bindings.txt
 | ||||
| +The available clocks are defined in dt-bindings/clock/mt*-clk.h.
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +ssusbsys: ssusbsys@1a000000 {
 | ||||
| +	compatible = "mediatek,mt7622-ssusbsys", "syscon";
 | ||||
| +	reg = <0 0x1a000000 0 0x1000>;
 | ||||
| +	#clock-cells = <1>;
 | ||||
| +};
 | ||||
| --- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | ||||
| @@ -9,6 +9,7 @@ Required Properties:
 | ||||
|  	- "mediatek,mt2701-topckgen" | ||||
|  	- "mediatek,mt2712-topckgen", "syscon" | ||||
|  	- "mediatek,mt6797-topckgen" | ||||
| +	- "mediatek,mt7622-topckgen"
 | ||||
|  	- "mediatek,mt8135-topckgen" | ||||
|  	- "mediatek,mt8173-topckgen" | ||||
|  - #clock-cells: Must be 1 | ||||
|  | @ -0,0 +1,310 @@ | |||
| From ea009d063f7a3d70831788046c7285a4af4ab82d Mon Sep 17 00:00:00 2001 | ||||
| From: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Date: Thu, 5 Oct 2017 11:50:25 +0800 | ||||
| Subject: [PATCH 149/224] clk: mediatek: add clocks dt-bindings required header | ||||
|  for MT7622 SoC | ||||
| 
 | ||||
| Add the required header for the entire clocks dt-bindings exported | ||||
| from topckgen, apmixedsys, infracfg, pericfg, ethsys, pciesys, ssusbsys | ||||
| and audsys which could be found on MT7622 SoC. | ||||
| 
 | ||||
| Signed-off-by: Chen Zhong <chen.zhong@mediatek.com> | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> | ||||
| ---
 | ||||
|  include/dt-bindings/clock/mt7622-clk.h | 289 +++++++++++++++++++++++++++++++++ | ||||
|  1 file changed, 289 insertions(+) | ||||
|  create mode 100644 include/dt-bindings/clock/mt7622-clk.h | ||||
| 
 | ||||
| --- /dev/null
 | ||||
| +++ b/include/dt-bindings/clock/mt7622-clk.h
 | ||||
| @@ -0,0 +1,289 @@
 | ||||
| +/*
 | ||||
| + * Copyright (c) 2017 MediaTek Inc.
 | ||||
| + * Author: Chen Zhong <chen.zhong@mediatek.com>
 | ||||
| + *
 | ||||
| + * This program is free software; you can redistribute it and/or modify
 | ||||
| + * it under the terms of the GNU General Public License version 2 as
 | ||||
| + * published by the Free Software Foundation.
 | ||||
| + *
 | ||||
| + * 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.
 | ||||
| + */
 | ||||
| +
 | ||||
| +#ifndef _DT_BINDINGS_CLK_MT7622_H
 | ||||
| +#define _DT_BINDINGS_CLK_MT7622_H
 | ||||
| +
 | ||||
| +/* TOPCKGEN */
 | ||||
| +
 | ||||
| +#define CLK_TOP_TO_U2_PHY		0
 | ||||
| +#define CLK_TOP_TO_U2_PHY_1P		1
 | ||||
| +#define CLK_TOP_PCIE0_PIPE_EN		2
 | ||||
| +#define CLK_TOP_PCIE1_PIPE_EN		3
 | ||||
| +#define CLK_TOP_SSUSB_TX250M		4
 | ||||
| +#define CLK_TOP_SSUSB_EQ_RX250M		5
 | ||||
| +#define CLK_TOP_SSUSB_CDR_REF		6
 | ||||
| +#define CLK_TOP_SSUSB_CDR_FB		7
 | ||||
| +#define CLK_TOP_SATA_ASIC		8
 | ||||
| +#define CLK_TOP_SATA_RBC		9
 | ||||
| +#define CLK_TOP_TO_USB3_SYS		10
 | ||||
| +#define CLK_TOP_P1_1MHZ			11
 | ||||
| +#define CLK_TOP_4MHZ			12
 | ||||
| +#define CLK_TOP_P0_1MHZ			13
 | ||||
| +#define CLK_TOP_TXCLK_SRC_PRE		14
 | ||||
| +#define CLK_TOP_RTC			15
 | ||||
| +#define CLK_TOP_MEMPLL			16
 | ||||
| +#define CLK_TOP_DMPLL			17
 | ||||
| +#define CLK_TOP_SYSPLL_D2		18
 | ||||
| +#define CLK_TOP_SYSPLL1_D2		19
 | ||||
| +#define CLK_TOP_SYSPLL1_D4		20
 | ||||
| +#define CLK_TOP_SYSPLL1_D8		21
 | ||||
| +#define CLK_TOP_SYSPLL2_D4		22
 | ||||
| +#define CLK_TOP_SYSPLL2_D8		23
 | ||||
| +#define CLK_TOP_SYSPLL_D5		24
 | ||||
| +#define CLK_TOP_SYSPLL3_D2		25
 | ||||
| +#define CLK_TOP_SYSPLL3_D4		26
 | ||||
| +#define CLK_TOP_SYSPLL4_D2		27
 | ||||
| +#define CLK_TOP_SYSPLL4_D4		28
 | ||||
| +#define CLK_TOP_SYSPLL4_D16		29
 | ||||
| +#define CLK_TOP_UNIVPLL			30
 | ||||
| +#define CLK_TOP_UNIVPLL_D2		31
 | ||||
| +#define CLK_TOP_UNIVPLL1_D2		32
 | ||||
| +#define CLK_TOP_UNIVPLL1_D4		33
 | ||||
| +#define CLK_TOP_UNIVPLL1_D8		34
 | ||||
| +#define CLK_TOP_UNIVPLL1_D16		35
 | ||||
| +#define CLK_TOP_UNIVPLL2_D2		36
 | ||||
| +#define CLK_TOP_UNIVPLL2_D4		37
 | ||||
| +#define CLK_TOP_UNIVPLL2_D8		38
 | ||||
| +#define CLK_TOP_UNIVPLL2_D16		39
 | ||||
| +#define CLK_TOP_UNIVPLL_D5		40
 | ||||
| +#define CLK_TOP_UNIVPLL3_D2		41
 | ||||
| +#define CLK_TOP_UNIVPLL3_D4		42
 | ||||
| +#define CLK_TOP_UNIVPLL3_D16		43
 | ||||
| +#define CLK_TOP_UNIVPLL_D7		44
 | ||||
| +#define CLK_TOP_UNIVPLL_D80_D4		45
 | ||||
| +#define CLK_TOP_UNIV48M			46
 | ||||
| +#define CLK_TOP_SGMIIPLL		47
 | ||||
| +#define CLK_TOP_SGMIIPLL_D2		48
 | ||||
| +#define CLK_TOP_AUD1PLL			49
 | ||||
| +#define CLK_TOP_AUD2PLL			50
 | ||||
| +#define CLK_TOP_AUD_I2S2_MCK		51
 | ||||
| +#define CLK_TOP_TO_USB3_REF		52
 | ||||
| +#define CLK_TOP_PCIE1_MAC_EN		53
 | ||||
| +#define CLK_TOP_PCIE0_MAC_EN		54
 | ||||
| +#define CLK_TOP_ETH_500M		55
 | ||||
| +#define CLK_TOP_AXI_SEL			56
 | ||||
| +#define CLK_TOP_MEM_SEL			57
 | ||||
| +#define CLK_TOP_DDRPHYCFG_SEL		58
 | ||||
| +#define CLK_TOP_ETH_SEL			59
 | ||||
| +#define CLK_TOP_PWM_SEL			60
 | ||||
| +#define CLK_TOP_F10M_REF_SEL		61
 | ||||
| +#define CLK_TOP_NFI_INFRA_SEL		62
 | ||||
| +#define CLK_TOP_FLASH_SEL		63
 | ||||
| +#define CLK_TOP_UART_SEL		64
 | ||||
| +#define CLK_TOP_SPI0_SEL		65
 | ||||
| +#define CLK_TOP_SPI1_SEL		66
 | ||||
| +#define CLK_TOP_MSDC50_0_SEL		67
 | ||||
| +#define CLK_TOP_MSDC30_0_SEL		68
 | ||||
| +#define CLK_TOP_MSDC30_1_SEL		69
 | ||||
| +#define CLK_TOP_A1SYS_HP_SEL		70
 | ||||
| +#define CLK_TOP_A2SYS_HP_SEL		71
 | ||||
| +#define CLK_TOP_INTDIR_SEL		72
 | ||||
| +#define CLK_TOP_AUD_INTBUS_SEL		73
 | ||||
| +#define CLK_TOP_PMICSPI_SEL		74
 | ||||
| +#define CLK_TOP_SCP_SEL			75
 | ||||
| +#define CLK_TOP_ATB_SEL			76
 | ||||
| +#define CLK_TOP_HIF_SEL			77
 | ||||
| +#define CLK_TOP_AUDIO_SEL		78
 | ||||
| +#define CLK_TOP_U2_SEL			79
 | ||||
| +#define CLK_TOP_AUD1_SEL		80
 | ||||
| +#define CLK_TOP_AUD2_SEL		81
 | ||||
| +#define CLK_TOP_IRRX_SEL		82
 | ||||
| +#define CLK_TOP_IRTX_SEL		83
 | ||||
| +#define CLK_TOP_ASM_L_SEL		84
 | ||||
| +#define CLK_TOP_ASM_M_SEL		85
 | ||||
| +#define CLK_TOP_ASM_H_SEL		86
 | ||||
| +#define CLK_TOP_APLL1_SEL		87
 | ||||
| +#define CLK_TOP_APLL2_SEL		88
 | ||||
| +#define CLK_TOP_I2S0_MCK_SEL		89
 | ||||
| +#define CLK_TOP_I2S1_MCK_SEL		90
 | ||||
| +#define CLK_TOP_I2S2_MCK_SEL		91
 | ||||
| +#define CLK_TOP_I2S3_MCK_SEL		92
 | ||||
| +#define CLK_TOP_APLL1_DIV		93
 | ||||
| +#define CLK_TOP_APLL2_DIV		94
 | ||||
| +#define CLK_TOP_I2S0_MCK_DIV		95
 | ||||
| +#define CLK_TOP_I2S1_MCK_DIV		96
 | ||||
| +#define CLK_TOP_I2S2_MCK_DIV		97
 | ||||
| +#define CLK_TOP_I2S3_MCK_DIV		98
 | ||||
| +#define CLK_TOP_A1SYS_HP_DIV		99
 | ||||
| +#define CLK_TOP_A2SYS_HP_DIV		100
 | ||||
| +#define CLK_TOP_APLL1_DIV_PD		101
 | ||||
| +#define CLK_TOP_APLL2_DIV_PD		102
 | ||||
| +#define CLK_TOP_I2S0_MCK_DIV_PD		103
 | ||||
| +#define CLK_TOP_I2S1_MCK_DIV_PD		104
 | ||||
| +#define CLK_TOP_I2S2_MCK_DIV_PD		105
 | ||||
| +#define CLK_TOP_I2S3_MCK_DIV_PD		106
 | ||||
| +#define CLK_TOP_A1SYS_HP_DIV_PD		107
 | ||||
| +#define CLK_TOP_A2SYS_HP_DIV_PD		108
 | ||||
| +#define CLK_TOP_NR_CLK			109
 | ||||
| +
 | ||||
| +/* INFRACFG */
 | ||||
| +
 | ||||
| +#define CLK_INFRA_MUX1_SEL		0
 | ||||
| +#define CLK_INFRA_DBGCLK_PD		1
 | ||||
| +#define CLK_INFRA_AUDIO_PD		2
 | ||||
| +#define CLK_INFRA_IRRX_PD		3
 | ||||
| +#define CLK_INFRA_APXGPT_PD		4
 | ||||
| +#define CLK_INFRA_PMIC_PD		5
 | ||||
| +#define CLK_INFRA_TRNG			6
 | ||||
| +#define CLK_INFRA_NR_CLK		7
 | ||||
| +
 | ||||
| +/* PERICFG */
 | ||||
| +
 | ||||
| +#define CLK_PERIBUS_SEL			0
 | ||||
| +#define CLK_PERI_THERM_PD		1
 | ||||
| +#define CLK_PERI_PWM1_PD		2
 | ||||
| +#define CLK_PERI_PWM2_PD		3
 | ||||
| +#define CLK_PERI_PWM3_PD		4
 | ||||
| +#define CLK_PERI_PWM4_PD		5
 | ||||
| +#define CLK_PERI_PWM5_PD		6
 | ||||
| +#define CLK_PERI_PWM6_PD		7
 | ||||
| +#define CLK_PERI_PWM7_PD		8
 | ||||
| +#define CLK_PERI_PWM_PD			9
 | ||||
| +#define CLK_PERI_AP_DMA_PD		10
 | ||||
| +#define CLK_PERI_MSDC30_0_PD		11
 | ||||
| +#define CLK_PERI_MSDC30_1_PD		12
 | ||||
| +#define CLK_PERI_UART0_PD		13
 | ||||
| +#define CLK_PERI_UART1_PD		14
 | ||||
| +#define CLK_PERI_UART2_PD		15
 | ||||
| +#define CLK_PERI_UART3_PD		16
 | ||||
| +#define CLK_PERI_UART4_PD		17
 | ||||
| +#define CLK_PERI_BTIF_PD		18
 | ||||
| +#define CLK_PERI_I2C0_PD		19
 | ||||
| +#define CLK_PERI_I2C1_PD		20
 | ||||
| +#define CLK_PERI_I2C2_PD		21
 | ||||
| +#define CLK_PERI_SPI1_PD		22
 | ||||
| +#define CLK_PERI_AUXADC_PD		23
 | ||||
| +#define CLK_PERI_SPI0_PD		24
 | ||||
| +#define CLK_PERI_SNFI_PD		25
 | ||||
| +#define CLK_PERI_NFI_PD			26
 | ||||
| +#define CLK_PERI_NFIECC_PD		27
 | ||||
| +#define CLK_PERI_FLASH_PD		28
 | ||||
| +#define CLK_PERI_IRTX_PD		29
 | ||||
| +#define CLK_PERI_NR_CLK			30
 | ||||
| +
 | ||||
| +/* APMIXEDSYS */
 | ||||
| +
 | ||||
| +#define CLK_APMIXED_ARMPLL		0
 | ||||
| +#define CLK_APMIXED_MAINPLL		1
 | ||||
| +#define CLK_APMIXED_UNIV2PLL		2
 | ||||
| +#define CLK_APMIXED_ETH1PLL		3
 | ||||
| +#define CLK_APMIXED_ETH2PLL		4
 | ||||
| +#define CLK_APMIXED_AUD1PLL		5
 | ||||
| +#define CLK_APMIXED_AUD2PLL		6
 | ||||
| +#define CLK_APMIXED_TRGPLL		7
 | ||||
| +#define CLK_APMIXED_SGMIPLL		8
 | ||||
| +#define CLK_APMIXED_MAIN_CORE_EN	9
 | ||||
| +#define CLK_APMIXED_NR_CLK		10
 | ||||
| +
 | ||||
| +/* AUDIOSYS */
 | ||||
| +
 | ||||
| +#define CLK_AUDIO_AFE			0
 | ||||
| +#define CLK_AUDIO_HDMI			1
 | ||||
| +#define CLK_AUDIO_SPDF			2
 | ||||
| +#define CLK_AUDIO_APLL			3
 | ||||
| +#define CLK_AUDIO_I2SIN1		4
 | ||||
| +#define CLK_AUDIO_I2SIN2		5
 | ||||
| +#define CLK_AUDIO_I2SIN3		6
 | ||||
| +#define CLK_AUDIO_I2SIN4		7
 | ||||
| +#define CLK_AUDIO_I2SO1			8
 | ||||
| +#define CLK_AUDIO_I2SO2			9
 | ||||
| +#define CLK_AUDIO_I2SO3			10
 | ||||
| +#define CLK_AUDIO_I2SO4			11
 | ||||
| +#define CLK_AUDIO_ASRCI1		12
 | ||||
| +#define CLK_AUDIO_ASRCI2		13
 | ||||
| +#define CLK_AUDIO_ASRCO1		14
 | ||||
| +#define CLK_AUDIO_ASRCO2		15
 | ||||
| +#define CLK_AUDIO_INTDIR		16
 | ||||
| +#define CLK_AUDIO_A1SYS			17
 | ||||
| +#define CLK_AUDIO_A2SYS			18
 | ||||
| +#define CLK_AUDIO_UL1			19
 | ||||
| +#define CLK_AUDIO_UL2			20
 | ||||
| +#define CLK_AUDIO_UL3			21
 | ||||
| +#define CLK_AUDIO_UL4			22
 | ||||
| +#define CLK_AUDIO_UL5			23
 | ||||
| +#define CLK_AUDIO_UL6			24
 | ||||
| +#define CLK_AUDIO_DL1			25
 | ||||
| +#define CLK_AUDIO_DL2			26
 | ||||
| +#define CLK_AUDIO_DL3			27
 | ||||
| +#define CLK_AUDIO_DL4			28
 | ||||
| +#define CLK_AUDIO_DL5			29
 | ||||
| +#define CLK_AUDIO_DL6			30
 | ||||
| +#define CLK_AUDIO_DLMCH			31
 | ||||
| +#define CLK_AUDIO_ARB1			32
 | ||||
| +#define CLK_AUDIO_AWB			33
 | ||||
| +#define CLK_AUDIO_AWB2			34
 | ||||
| +#define CLK_AUDIO_DAI			35
 | ||||
| +#define CLK_AUDIO_MOD			36
 | ||||
| +#define CLK_AUDIO_ASRCI3		37
 | ||||
| +#define CLK_AUDIO_ASRCI4		38
 | ||||
| +#define CLK_AUDIO_ASRCO3		39
 | ||||
| +#define CLK_AUDIO_ASRCO4		40
 | ||||
| +#define CLK_AUDIO_MEM_ASRC1		41
 | ||||
| +#define CLK_AUDIO_MEM_ASRC2		42
 | ||||
| +#define CLK_AUDIO_MEM_ASRC3		43
 | ||||
| +#define CLK_AUDIO_MEM_ASRC4		44
 | ||||
| +#define CLK_AUDIO_MEM_ASRC5		45
 | ||||
| +#define CLK_AUDIO_NR_CLK		46
 | ||||
| +
 | ||||
| +/* SSUSBSYS */
 | ||||
| +
 | ||||
| +#define CLK_SSUSB_U2_PHY_1P_EN		0
 | ||||
| +#define CLK_SSUSB_U2_PHY_EN		1
 | ||||
| +#define CLK_SSUSB_REF_EN		2
 | ||||
| +#define CLK_SSUSB_SYS_EN		3
 | ||||
| +#define CLK_SSUSB_MCU_EN		4
 | ||||
| +#define CLK_SSUSB_DMA_EN		5
 | ||||
| +#define CLK_SSUSB_NR_CLK		6
 | ||||
| +
 | ||||
| +/* PCIESYS */
 | ||||
| +
 | ||||
| +#define CLK_PCIE_P1_AUX_EN		0
 | ||||
| +#define CLK_PCIE_P1_OBFF_EN		1
 | ||||
| +#define CLK_PCIE_P1_AHB_EN		2
 | ||||
| +#define CLK_PCIE_P1_AXI_EN		3
 | ||||
| +#define CLK_PCIE_P1_MAC_EN		4
 | ||||
| +#define CLK_PCIE_P1_PIPE_EN		5
 | ||||
| +#define CLK_PCIE_P0_AUX_EN		6
 | ||||
| +#define CLK_PCIE_P0_OBFF_EN		7
 | ||||
| +#define CLK_PCIE_P0_AHB_EN		8
 | ||||
| +#define CLK_PCIE_P0_AXI_EN		9
 | ||||
| +#define CLK_PCIE_P0_MAC_EN		10
 | ||||
| +#define CLK_PCIE_P0_PIPE_EN		11
 | ||||
| +#define CLK_SATA_AHB_EN			12
 | ||||
| +#define CLK_SATA_AXI_EN			13
 | ||||
| +#define CLK_SATA_ASIC_EN		14
 | ||||
| +#define CLK_SATA_RBC_EN			15
 | ||||
| +#define CLK_SATA_PM_EN			16
 | ||||
| +#define CLK_PCIE_NR_CLK			17
 | ||||
| +
 | ||||
| +/* ETHSYS */
 | ||||
| +
 | ||||
| +#define CLK_ETH_HSDMA_EN		0
 | ||||
| +#define CLK_ETH_ESW_EN			1
 | ||||
| +#define CLK_ETH_GP2_EN			2
 | ||||
| +#define CLK_ETH_GP1_EN			3
 | ||||
| +#define CLK_ETH_GP0_EN			4
 | ||||
| +#define CLK_ETH_NR_CLK			5
 | ||||
| +
 | ||||
| +/* SGMIISYS */
 | ||||
| +
 | ||||
| +#define CLK_SGMII_TX250M_EN		0
 | ||||
| +#define CLK_SGMII_RX250M_EN		1
 | ||||
| +#define CLK_SGMII_CDR_REF		2
 | ||||
| +#define CLK_SGMII_CDR_FB		3
 | ||||
| +#define CLK_SGMII_NR_CLK		4
 | ||||
| +
 | ||||
| +#endif /* _DT_BINDINGS_CLK_MT7622_H */
 | ||||
| +
 | ||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -0,0 +1,61 @@ | |||
| From fa69904d3b7357a5be43771f764e10fd99ebbb11 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:30 +0800 | ||||
| Subject: [PATCH 151/224] arm64: dts: mt8173: remove "mediatek, mt8135-mmc" | ||||
|  from mmc nodes | ||||
| 
 | ||||
| devicetree bindings has been updated to support multi-platforms, | ||||
| so that each platform has its owns compatible name. | ||||
| And, this compatible name may used in driver to distinguish with | ||||
| other platform. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| Acked-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| ---
 | ||||
|  arch/arm64/boot/dts/mediatek/mt8173.dtsi | 12 ++++-------- | ||||
|  1 file changed, 4 insertions(+), 8 deletions(-) | ||||
| 
 | ||||
| --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
 | ||||
| +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
 | ||||
| @@ -684,8 +684,7 @@
 | ||||
|  		}; | ||||
|   | ||||
|  		mmc0: mmc@11230000 { | ||||
| -			compatible = "mediatek,mt8173-mmc",
 | ||||
| -				     "mediatek,mt8135-mmc";
 | ||||
| +			compatible = "mediatek,mt8173-mmc";
 | ||||
|  			reg = <0 0x11230000 0 0x1000>; | ||||
|  			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_LOW>; | ||||
|  			clocks = <&pericfg CLK_PERI_MSDC30_0>, | ||||
| @@ -695,8 +694,7 @@
 | ||||
|  		}; | ||||
|   | ||||
|  		mmc1: mmc@11240000 { | ||||
| -			compatible = "mediatek,mt8173-mmc",
 | ||||
| -				     "mediatek,mt8135-mmc";
 | ||||
| +			compatible = "mediatek,mt8173-mmc";
 | ||||
|  			reg = <0 0x11240000 0 0x1000>; | ||||
|  			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>; | ||||
|  			clocks = <&pericfg CLK_PERI_MSDC30_1>, | ||||
| @@ -706,8 +704,7 @@
 | ||||
|  		}; | ||||
|   | ||||
|  		mmc2: mmc@11250000 { | ||||
| -			compatible = "mediatek,mt8173-mmc",
 | ||||
| -				     "mediatek,mt8135-mmc";
 | ||||
| +			compatible = "mediatek,mt8173-mmc";
 | ||||
|  			reg = <0 0x11250000 0 0x1000>; | ||||
|  			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_LOW>; | ||||
|  			clocks = <&pericfg CLK_PERI_MSDC30_2>, | ||||
| @@ -717,8 +714,7 @@
 | ||||
|  		}; | ||||
|   | ||||
|  		mmc3: mmc@11260000 { | ||||
| -			compatible = "mediatek,mt8173-mmc",
 | ||||
| -				     "mediatek,mt8135-mmc";
 | ||||
| +			compatible = "mediatek,mt8173-mmc";
 | ||||
|  			reg = <0 0x11260000 0 0x1000>; | ||||
|  			interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_LOW>; | ||||
|  			clocks = <&pericfg CLK_PERI_MSDC30_3>, | ||||
|  | @ -0,0 +1,70 @@ | |||
| From bc70c7f1174b937af2784977281a1567f69dd2b6 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:31 +0800 | ||||
| Subject: [PATCH 152/224] mmc: mediatek: make hs400_tune_response only for | ||||
|  mt8173 | ||||
| 
 | ||||
| the origin design of hs400_tune_response is for mt8173 because of | ||||
| mt8173 has a special design. for doing that, we add a new member | ||||
| "compatible", by now it's only for mt8173. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 11 +++++++++-- | ||||
|  1 file changed, 9 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -300,6 +300,7 @@ struct msdc_save_para {
 | ||||
|   | ||||
|  struct mtk_mmc_compatible { | ||||
|  	u8 clk_div_bits; | ||||
| +	bool hs400_tune; /* only used for MT8173 */
 | ||||
|  }; | ||||
|   | ||||
|  struct msdc_tune_para { | ||||
| @@ -360,18 +361,22 @@ struct msdc_host {
 | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8135_compat = { | ||||
|  	.clk_div_bits = 8, | ||||
| +	.hs400_tune = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8173_compat = { | ||||
|  	.clk_div_bits = 8, | ||||
| +	.hs400_tune = true,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2701_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
| +	.hs400_tune = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2712_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
| +	.hs400_tune = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id msdc_of_ids[] = { | ||||
| @@ -666,7 +671,8 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  		       host->base + PAD_CMD_TUNE); | ||||
|  	} | ||||
|   | ||||
| -	if (timing == MMC_TIMING_MMC_HS400)
 | ||||
| +	if (timing == MMC_TIMING_MMC_HS400 &&
 | ||||
| +	    host->dev_comp->hs400_tune)
 | ||||
|  		sdr_set_field(host->base + PAD_CMD_TUNE, | ||||
|  			      MSDC_PAD_TUNE_CMDRRDLY, | ||||
|  			      host->hs400_cmd_int_delay); | ||||
| @@ -1594,7 +1600,8 @@ static int msdc_execute_tuning(struct mm
 | ||||
|  	struct msdc_host *host = mmc_priv(mmc); | ||||
|  	int ret; | ||||
|   | ||||
| -	if (host->hs400_mode)
 | ||||
| +	if (host->hs400_mode &&
 | ||||
| +	    host->dev_comp->hs400_tune)
 | ||||
|  		ret = hs400_tune_response(mmc, opcode); | ||||
|  	else | ||||
|  		ret = msdc_tune_response(mmc, opcode); | ||||
|  | @ -0,0 +1,256 @@ | |||
| From a10349f1710a11239c58da3a7e5b353c6b2070c2 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:32 +0800 | ||||
| Subject: [PATCH 153/224] mmc: mediatek: add pad_tune0 support | ||||
| 
 | ||||
| from mt2701, the register of PAD_TUNE has been phased out, | ||||
| while there is a new register of PAD_TUNE0 | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 51 ++++++++++++++++++++++++++++++----------------- | ||||
|  1 file changed, 33 insertions(+), 18 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -75,6 +75,7 @@
 | ||||
|  #define MSDC_PATCH_BIT   0xb0 | ||||
|  #define MSDC_PATCH_BIT1  0xb4 | ||||
|  #define MSDC_PAD_TUNE    0xec | ||||
| +#define MSDC_PAD_TUNE0   0xf0
 | ||||
|  #define PAD_DS_TUNE      0x188 | ||||
|  #define PAD_CMD_TUNE     0x18c | ||||
|  #define EMMC50_CFG0      0x208 | ||||
| @@ -301,6 +302,7 @@ struct msdc_save_para {
 | ||||
|  struct mtk_mmc_compatible { | ||||
|  	u8 clk_div_bits; | ||||
|  	bool hs400_tune; /* only used for MT8173 */ | ||||
| +	u32 pad_tune_reg;
 | ||||
|  }; | ||||
|   | ||||
|  struct msdc_tune_para { | ||||
| @@ -362,21 +364,25 @@ struct msdc_host {
 | ||||
|  static const struct mtk_mmc_compatible mt8135_compat = { | ||||
|  	.clk_div_bits = 8, | ||||
|  	.hs400_tune = false, | ||||
| +	.pad_tune_reg = MSDC_PAD_TUNE,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8173_compat = { | ||||
|  	.clk_div_bits = 8, | ||||
|  	.hs400_tune = true, | ||||
| +	.pad_tune_reg = MSDC_PAD_TUNE,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2701_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
|  	.hs400_tune = false, | ||||
| +	.pad_tune_reg = MSDC_PAD_TUNE0,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2712_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
|  	.hs400_tune = false, | ||||
| +	.pad_tune_reg = MSDC_PAD_TUNE0,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id msdc_of_ids[] = { | ||||
| @@ -581,6 +587,7 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  	u32 flags; | ||||
|  	u32 div; | ||||
|  	u32 sclk; | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
|   | ||||
|  	if (!hz) { | ||||
|  		dev_dbg(host->dev, "set mclk to 0\n"); | ||||
| @@ -663,10 +670,10 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  	 */ | ||||
|  	if (host->sclk <= 52000000) { | ||||
|  		writel(host->def_tune_para.iocon, host->base + MSDC_IOCON); | ||||
| -		writel(host->def_tune_para.pad_tune, host->base + MSDC_PAD_TUNE);
 | ||||
| +		writel(host->def_tune_para.pad_tune, host->base + tune_reg);
 | ||||
|  	} else { | ||||
|  		writel(host->saved_tune_para.iocon, host->base + MSDC_IOCON); | ||||
| -		writel(host->saved_tune_para.pad_tune, host->base + MSDC_PAD_TUNE);
 | ||||
| +		writel(host->saved_tune_para.pad_tune, host->base + tune_reg);
 | ||||
|  		writel(host->saved_tune_para.pad_cmd_tune, | ||||
|  		       host->base + PAD_CMD_TUNE); | ||||
|  	} | ||||
| @@ -1224,6 +1231,7 @@ static irqreturn_t msdc_irq(int irq, voi
 | ||||
|  static void msdc_init_hw(struct msdc_host *host) | ||||
|  { | ||||
|  	u32 val; | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
|   | ||||
|  	/* Configure to MMC/SD mode, clock free running */ | ||||
|  	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN); | ||||
| @@ -1239,7 +1247,7 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|  	val = readl(host->base + MSDC_INT); | ||||
|  	writel(val, host->base + MSDC_INT); | ||||
|   | ||||
| -	writel(0, host->base + MSDC_PAD_TUNE);
 | ||||
| +	writel(0, host->base + tune_reg);
 | ||||
|  	writel(0, host->base + MSDC_IOCON); | ||||
|  	sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 0); | ||||
|  	writel(0x403c0046, host->base + MSDC_PATCH_BIT); | ||||
| @@ -1259,7 +1267,7 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|  	sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3); | ||||
|   | ||||
|  	host->def_tune_para.iocon = readl(host->base + MSDC_IOCON); | ||||
| -	host->def_tune_para.pad_tune = readl(host->base + MSDC_PAD_TUNE);
 | ||||
| +	host->def_tune_para.pad_tune = readl(host->base + tune_reg);
 | ||||
|  	dev_dbg(host->dev, "init hardware done!"); | ||||
|  } | ||||
|   | ||||
| @@ -1402,18 +1410,19 @@ static int msdc_tune_response(struct mmc
 | ||||
|  	struct msdc_delay_phase internal_delay_phase; | ||||
|  	u8 final_delay, final_maxlen; | ||||
|  	u32 internal_delay = 0; | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
|  	int cmd_err; | ||||
|  	int i, j; | ||||
|   | ||||
|  	if (mmc->ios.timing == MMC_TIMING_MMC_HS200 || | ||||
|  	    mmc->ios.timing == MMC_TIMING_UHS_SDR104) | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_CMDRRDLY, | ||||
|  			      host->hs200_cmd_int_delay); | ||||
|   | ||||
|  	sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); | ||||
|  	for (i = 0 ; i < PAD_DELAY_MAX; i++) { | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_CMDRDLY, i); | ||||
|  		/* | ||||
|  		 * Using the same parameters, it may sometimes pass the test, | ||||
| @@ -1437,7 +1446,7 @@ static int msdc_tune_response(struct mmc
 | ||||
|   | ||||
|  	sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); | ||||
|  	for (i = 0; i < PAD_DELAY_MAX; i++) { | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_CMDRDLY, i); | ||||
|  		/* | ||||
|  		 * Using the same parameters, it may sometimes pass the test, | ||||
| @@ -1462,12 +1471,12 @@ skip_fall:
 | ||||
|  		final_maxlen = final_fall_delay.maxlen; | ||||
|  	if (final_maxlen == final_rise_delay.maxlen) { | ||||
|  		sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRDLY,
 | ||||
| +		sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_CMDRDLY,
 | ||||
|  			      final_rise_delay.final_phase); | ||||
|  		final_delay = final_rise_delay.final_phase; | ||||
|  	} else { | ||||
|  		sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRDLY,
 | ||||
| +		sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_CMDRDLY,
 | ||||
|  			      final_fall_delay.final_phase); | ||||
|  		final_delay = final_fall_delay.final_phase; | ||||
|  	} | ||||
| @@ -1475,7 +1484,7 @@ skip_fall:
 | ||||
|  		goto skip_internal; | ||||
|   | ||||
|  	for (i = 0; i < PAD_DELAY_MAX; i++) { | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_CMDRRDLY, i); | ||||
|  		mmc_send_tuning(mmc, opcode, &cmd_err); | ||||
|  		if (!cmd_err) | ||||
| @@ -1483,7 +1492,7 @@ skip_fall:
 | ||||
|  	} | ||||
|  	dev_dbg(host->dev, "Final internal delay: 0x%x\n", internal_delay); | ||||
|  	internal_delay_phase = get_best_delay(host, internal_delay); | ||||
| -	sdr_set_field(host->base + MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY,
 | ||||
| +	sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_CMDRRDLY,
 | ||||
|  		      internal_delay_phase.final_phase); | ||||
|  skip_internal: | ||||
|  	dev_dbg(host->dev, "Final cmd pad delay: %x\n", final_delay); | ||||
| @@ -1545,12 +1554,13 @@ static int msdc_tune_data(struct mmc_hos
 | ||||
|  	u32 rise_delay = 0, fall_delay = 0; | ||||
|  	struct msdc_delay_phase final_rise_delay, final_fall_delay = { 0,}; | ||||
|  	u8 final_delay, final_maxlen; | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
|  	int i, ret; | ||||
|   | ||||
|  	sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); | ||||
|  	sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); | ||||
|  	for (i = 0 ; i < PAD_DELAY_MAX; i++) { | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_DATRRDLY, i); | ||||
|  		ret = mmc_send_tuning(mmc, opcode, NULL); | ||||
|  		if (!ret) | ||||
| @@ -1565,7 +1575,7 @@ static int msdc_tune_data(struct mmc_hos
 | ||||
|  	sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); | ||||
|  	sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); | ||||
|  	for (i = 0; i < PAD_DELAY_MAX; i++) { | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_DATRRDLY, i); | ||||
|  		ret = mmc_send_tuning(mmc, opcode, NULL); | ||||
|  		if (!ret) | ||||
| @@ -1578,14 +1588,14 @@ skip_fall:
 | ||||
|  	if (final_maxlen == final_rise_delay.maxlen) { | ||||
|  		sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); | ||||
|  		sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_DATRRDLY, | ||||
|  			      final_rise_delay.final_phase); | ||||
|  		final_delay = final_rise_delay.final_phase; | ||||
|  	} else { | ||||
|  		sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); | ||||
|  		sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); | ||||
| -		sdr_set_field(host->base + MSDC_PAD_TUNE,
 | ||||
| +		sdr_set_field(host->base + tune_reg,
 | ||||
|  			      MSDC_PAD_TUNE_DATRRDLY, | ||||
|  			      final_fall_delay.final_phase); | ||||
|  		final_delay = final_fall_delay.final_phase; | ||||
| @@ -1599,6 +1609,7 @@ static int msdc_execute_tuning(struct mm
 | ||||
|  { | ||||
|  	struct msdc_host *host = mmc_priv(mmc); | ||||
|  	int ret; | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
|   | ||||
|  	if (host->hs400_mode && | ||||
|  	    host->dev_comp->hs400_tune) | ||||
| @@ -1616,7 +1627,7 @@ static int msdc_execute_tuning(struct mm
 | ||||
|  	} | ||||
|   | ||||
|  	host->saved_tune_para.iocon = readl(host->base + MSDC_IOCON); | ||||
| -	host->saved_tune_para.pad_tune = readl(host->base + MSDC_PAD_TUNE);
 | ||||
| +	host->saved_tune_para.pad_tune = readl(host->base + tune_reg);
 | ||||
|  	host->saved_tune_para.pad_cmd_tune = readl(host->base + PAD_CMD_TUNE); | ||||
|  	return ret; | ||||
|  } | ||||
| @@ -1857,10 +1868,12 @@ static int msdc_drv_remove(struct platfo
 | ||||
|  #ifdef CONFIG_PM | ||||
|  static void msdc_save_reg(struct msdc_host *host) | ||||
|  { | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
| +
 | ||||
|  	host->save_para.msdc_cfg = readl(host->base + MSDC_CFG); | ||||
|  	host->save_para.iocon = readl(host->base + MSDC_IOCON); | ||||
|  	host->save_para.sdc_cfg = readl(host->base + SDC_CFG); | ||||
| -	host->save_para.pad_tune = readl(host->base + MSDC_PAD_TUNE);
 | ||||
| +	host->save_para.pad_tune = readl(host->base + tune_reg);
 | ||||
|  	host->save_para.patch_bit0 = readl(host->base + MSDC_PATCH_BIT); | ||||
|  	host->save_para.patch_bit1 = readl(host->base + MSDC_PATCH_BIT1); | ||||
|  	host->save_para.pad_ds_tune = readl(host->base + PAD_DS_TUNE); | ||||
| @@ -1870,10 +1883,12 @@ static void msdc_save_reg(struct msdc_ho
 | ||||
|   | ||||
|  static void msdc_restore_reg(struct msdc_host *host) | ||||
|  { | ||||
| +	u32 tune_reg = host->dev_comp->pad_tune_reg;
 | ||||
| +
 | ||||
|  	writel(host->save_para.msdc_cfg, host->base + MSDC_CFG); | ||||
|  	writel(host->save_para.iocon, host->base + MSDC_IOCON); | ||||
|  	writel(host->save_para.sdc_cfg, host->base + SDC_CFG); | ||||
| -	writel(host->save_para.pad_tune, host->base + MSDC_PAD_TUNE);
 | ||||
| +	writel(host->save_para.pad_tune, host->base + tune_reg);
 | ||||
|  	writel(host->save_para.patch_bit0, host->base + MSDC_PATCH_BIT); | ||||
|  	writel(host->save_para.patch_bit1, host->base + MSDC_PATCH_BIT1); | ||||
|  	writel(host->save_para.pad_ds_tune, host->base + PAD_DS_TUNE); | ||||
|  | @ -0,0 +1,170 @@ | |||
| From 830574225e621809600902b69bbdd563e67ef4eb Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:33 +0800 | ||||
| Subject: [PATCH 154/224] mmc: mediatek: add async fifo and data tune support | ||||
| 
 | ||||
| mt2701/mt2712 supports async fifo & data tune, which can improve | ||||
| host stability. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-- | ||||
|  1 file changed, 50 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -74,6 +74,7 @@
 | ||||
|  #define MSDC_DMA_CFG     0x9c | ||||
|  #define MSDC_PATCH_BIT   0xb0 | ||||
|  #define MSDC_PATCH_BIT1  0xb4 | ||||
| +#define MSDC_PATCH_BIT2  0xb8
 | ||||
|  #define MSDC_PAD_TUNE    0xec | ||||
|  #define MSDC_PAD_TUNE0   0xf0 | ||||
|  #define PAD_DS_TUNE      0x188 | ||||
| @@ -216,11 +217,20 @@
 | ||||
|  #define MSDC_PATCH_BIT_SPCPUSH    (0x1 << 29)	/* RW */ | ||||
|  #define MSDC_PATCH_BIT_DECRCTMO   (0x1 << 30)	/* RW */ | ||||
|   | ||||
| +#define MSDC_PATCH_BIT2_CFGRESP   (0x1 << 15)   /* RW */
 | ||||
| +#define MSDC_PATCH_BIT2_CFGCRCSTS (0x1 << 28)   /* RW */
 | ||||
| +#define MSDC_PB2_RESPWAIT         (0x3 << 2)    /* RW */
 | ||||
| +#define MSDC_PB2_RESPSTSENSEL     (0x7 << 16)   /* RW */
 | ||||
| +#define MSDC_PB2_CRCSTSENSEL      (0x7 << 29)   /* RW */
 | ||||
| +
 | ||||
|  #define MSDC_PAD_TUNE_DATWRDLY	  (0x1f <<  0)	/* RW */ | ||||
|  #define MSDC_PAD_TUNE_DATRRDLY	  (0x1f <<  8)	/* RW */ | ||||
|  #define MSDC_PAD_TUNE_CMDRDLY	  (0x1f << 16)  /* RW */ | ||||
|  #define MSDC_PAD_TUNE_CMDRRDLY	  (0x1f << 22)	/* RW */ | ||||
|  #define MSDC_PAD_TUNE_CLKTDLY	  (0x1f << 27)  /* RW */ | ||||
| +#define MSDC_PAD_TUNE_RXDLYSEL	  (0x1 << 15)   /* RW */
 | ||||
| +#define MSDC_PAD_TUNE_RD_SEL	  (0x1 << 13)   /* RW */
 | ||||
| +#define MSDC_PAD_TUNE_CMD_SEL	  (0x1 << 21)   /* RW */
 | ||||
|   | ||||
|  #define PAD_DS_TUNE_DLY1	  (0x1f << 2)   /* RW */ | ||||
|  #define PAD_DS_TUNE_DLY2	  (0x1f << 7)   /* RW */ | ||||
| @@ -294,6 +304,7 @@ struct msdc_save_para {
 | ||||
|  	u32 pad_tune; | ||||
|  	u32 patch_bit0; | ||||
|  	u32 patch_bit1; | ||||
| +	u32 patch_bit2;
 | ||||
|  	u32 pad_ds_tune; | ||||
|  	u32 pad_cmd_tune; | ||||
|  	u32 emmc50_cfg0; | ||||
| @@ -303,6 +314,8 @@ struct mtk_mmc_compatible {
 | ||||
|  	u8 clk_div_bits; | ||||
|  	bool hs400_tune; /* only used for MT8173 */ | ||||
|  	u32 pad_tune_reg; | ||||
| +	bool async_fifo;
 | ||||
| +	bool data_tune;
 | ||||
|  }; | ||||
|   | ||||
|  struct msdc_tune_para { | ||||
| @@ -365,24 +378,32 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.clk_div_bits = 8, | ||||
|  	.hs400_tune = false, | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE, | ||||
| +	.async_fifo = false,
 | ||||
| +	.data_tune = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8173_compat = { | ||||
|  	.clk_div_bits = 8, | ||||
|  	.hs400_tune = true, | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE, | ||||
| +	.async_fifo = false,
 | ||||
| +	.data_tune = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2701_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
|  	.hs400_tune = false, | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE0, | ||||
| +	.async_fifo = true,
 | ||||
| +	.data_tune = true,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2712_compat = { | ||||
|  	.clk_div_bits = 12, | ||||
|  	.hs400_tune = false, | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE0, | ||||
| +	.async_fifo = true,
 | ||||
| +	.data_tune = true,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id msdc_of_ids[] = { | ||||
| @@ -1252,8 +1273,29 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|  	sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 0); | ||||
|  	writel(0x403c0046, host->base + MSDC_PATCH_BIT); | ||||
|  	sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_CKGEN_MSDC_DLY_SEL, 1); | ||||
| -	writel(0xffff0089, host->base + MSDC_PATCH_BIT1);
 | ||||
| +	writel(0xffff4089, host->base + MSDC_PATCH_BIT1);
 | ||||
|  	sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL); | ||||
| +	if (host->dev_comp->async_fifo) {
 | ||||
| +		sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| +			      MSDC_PB2_RESPWAIT, 3);
 | ||||
| +		sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| +			      MSDC_PB2_RESPSTSENSEL, 2);
 | ||||
| +		sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| +			      MSDC_PB2_CRCSTSENSEL, 2);
 | ||||
| +		/* use async fifo, then no need tune internal delay */
 | ||||
| +		sdr_clr_bits(host->base + MSDC_PATCH_BIT2,
 | ||||
| +			     MSDC_PATCH_BIT2_CFGRESP);
 | ||||
| +		sdr_set_bits(host->base + MSDC_PATCH_BIT2,
 | ||||
| +			     MSDC_PATCH_BIT2_CFGCRCSTS);
 | ||||
| +	}
 | ||||
| +
 | ||||
| +	if (host->dev_comp->data_tune) {
 | ||||
| +		sdr_set_bits(host->base + tune_reg,
 | ||||
| +			     MSDC_PAD_TUNE_RD_SEL | MSDC_PAD_TUNE_CMD_SEL);
 | ||||
| +	} else {
 | ||||
| +		/* choose clock tune */
 | ||||
| +		sdr_set_bits(host->base + tune_reg, MSDC_PAD_TUNE_RXDLYSEL);
 | ||||
| +	}
 | ||||
|   | ||||
|  	/* Configure to enable SDIO mode. | ||||
|  	 * it's must otherwise sdio cmd5 failed | ||||
| @@ -1268,6 +1310,8 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|   | ||||
|  	host->def_tune_para.iocon = readl(host->base + MSDC_IOCON); | ||||
|  	host->def_tune_para.pad_tune = readl(host->base + tune_reg); | ||||
| +	host->saved_tune_para.iocon = readl(host->base + MSDC_IOCON);
 | ||||
| +	host->saved_tune_para.pad_tune = readl(host->base + tune_reg);
 | ||||
|  	dev_dbg(host->dev, "init hardware done!"); | ||||
|  } | ||||
|   | ||||
| @@ -1480,7 +1524,7 @@ skip_fall:
 | ||||
|  			      final_fall_delay.final_phase); | ||||
|  		final_delay = final_fall_delay.final_phase; | ||||
|  	} | ||||
| -	if (host->hs200_cmd_int_delay)
 | ||||
| +	if (host->dev_comp->async_fifo || host->hs200_cmd_int_delay)
 | ||||
|  		goto skip_internal; | ||||
|   | ||||
|  	for (i = 0; i < PAD_DELAY_MAX; i++) { | ||||
| @@ -1638,6 +1682,8 @@ static int msdc_prepare_hs400_tuning(str
 | ||||
|  	host->hs400_mode = true; | ||||
|   | ||||
|  	writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE); | ||||
| +	/* hs400 mode must set it to 0 */
 | ||||
| +	sdr_clr_bits(host->base + MSDC_PATCH_BIT2, MSDC_PATCH_BIT2_CFGCRCSTS);
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| @@ -1876,6 +1922,7 @@ static void msdc_save_reg(struct msdc_ho
 | ||||
|  	host->save_para.pad_tune = readl(host->base + tune_reg); | ||||
|  	host->save_para.patch_bit0 = readl(host->base + MSDC_PATCH_BIT); | ||||
|  	host->save_para.patch_bit1 = readl(host->base + MSDC_PATCH_BIT1); | ||||
| +	host->save_para.patch_bit2 = readl(host->base + MSDC_PATCH_BIT2);
 | ||||
|  	host->save_para.pad_ds_tune = readl(host->base + PAD_DS_TUNE); | ||||
|  	host->save_para.pad_cmd_tune = readl(host->base + PAD_CMD_TUNE); | ||||
|  	host->save_para.emmc50_cfg0 = readl(host->base + EMMC50_CFG0); | ||||
| @@ -1891,6 +1938,7 @@ static void msdc_restore_reg(struct msdc
 | ||||
|  	writel(host->save_para.pad_tune, host->base + tune_reg); | ||||
|  	writel(host->save_para.patch_bit0, host->base + MSDC_PATCH_BIT); | ||||
|  	writel(host->save_para.patch_bit1, host->base + MSDC_PATCH_BIT1); | ||||
| +	writel(host->save_para.patch_bit2, host->base + MSDC_PATCH_BIT2);
 | ||||
|  	writel(host->save_para.pad_ds_tune, host->base + PAD_DS_TUNE); | ||||
|  	writel(host->save_para.pad_cmd_tune, host->base + PAD_CMD_TUNE); | ||||
|  	writel(host->save_para.emmc50_cfg0, host->base + EMMC50_CFG0); | ||||
|  | @ -0,0 +1,67 @@ | |||
| From 788d269aee4c612d5cd97b896ea5d22f19137097 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:34 +0800 | ||||
| Subject: [PATCH 155/224] mmc: mediatek: add busy_check support | ||||
| 
 | ||||
| bit7 of PATCH_BIT1 has different meaning in new design, to | ||||
| compatible with previous platform, clear this bit in new | ||||
| platform. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 7 +++++++ | ||||
|  1 file changed, 7 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -316,6 +316,7 @@ struct mtk_mmc_compatible {
 | ||||
|  	u32 pad_tune_reg; | ||||
|  	bool async_fifo; | ||||
|  	bool data_tune; | ||||
| +	bool busy_check;
 | ||||
|  }; | ||||
|   | ||||
|  struct msdc_tune_para { | ||||
| @@ -380,6 +381,7 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE, | ||||
|  	.async_fifo = false, | ||||
|  	.data_tune = false, | ||||
| +	.busy_check = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8173_compat = { | ||||
| @@ -388,6 +390,7 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE, | ||||
|  	.async_fifo = false, | ||||
|  	.data_tune = false, | ||||
| +	.busy_check = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2701_compat = { | ||||
| @@ -396,6 +399,7 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE0, | ||||
|  	.async_fifo = true, | ||||
|  	.data_tune = true, | ||||
| +	.busy_check = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2712_compat = { | ||||
| @@ -404,6 +408,7 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.pad_tune_reg = MSDC_PAD_TUNE0, | ||||
|  	.async_fifo = true, | ||||
|  	.data_tune = true, | ||||
| +	.busy_check = true,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id msdc_of_ids[] = { | ||||
| @@ -1275,6 +1280,8 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|  	sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_CKGEN_MSDC_DLY_SEL, 1); | ||||
|  	writel(0xffff4089, host->base + MSDC_PATCH_BIT1); | ||||
|  	sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL); | ||||
| +	if (host->dev_comp->busy_check)
 | ||||
| +		sdr_clr_bits(host->base + MSDC_PATCH_BIT1, (1 << 7));
 | ||||
|  	if (host->dev_comp->async_fifo) { | ||||
|  		sdr_set_field(host->base + MSDC_PATCH_BIT2, | ||||
|  			      MSDC_PB2_RESPWAIT, 3); | ||||
|  | @ -0,0 +1,168 @@ | |||
| From 9257240bcaf8f9ee6878357e00e7ab511ad6d325 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:35 +0800 | ||||
| Subject: [PATCH 156/224] mmc: mediatek: add stop_clk fix and enhance_rx | ||||
|  support | ||||
| 
 | ||||
| mt2712 supports stop_clk fix and enhance_rx, which can improve | ||||
| host stability. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- | ||||
|  1 file changed, 43 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -67,6 +67,7 @@
 | ||||
|  #define SDC_RESP2        0x48 | ||||
|  #define SDC_RESP3        0x4c | ||||
|  #define SDC_BLK_NUM      0x50 | ||||
| +#define SDC_ADV_CFG0     0x64
 | ||||
|  #define EMMC_IOCON       0x7c | ||||
|  #define SDC_ACMD_RESP    0x80 | ||||
|  #define MSDC_DMA_SA      0x90 | ||||
| @@ -80,6 +81,7 @@
 | ||||
|  #define PAD_DS_TUNE      0x188 | ||||
|  #define PAD_CMD_TUNE     0x18c | ||||
|  #define EMMC50_CFG0      0x208 | ||||
| +#define SDC_FIFO_CFG     0x228
 | ||||
|   | ||||
|  /*--------------------------------------------------------------------------*/ | ||||
|  /* Register Mask                                                            */ | ||||
| @@ -188,6 +190,9 @@
 | ||||
|  #define SDC_STS_CMDBUSY         (0x1 << 1)	/* RW */ | ||||
|  #define SDC_STS_SWR_COMPL       (0x1 << 31)	/* RW */ | ||||
|   | ||||
| +/* SDC_ADV_CFG0 mask */
 | ||||
| +#define SDC_RX_ENHANCE_EN	(0x1 << 20)	/* RW */
 | ||||
| +
 | ||||
|  /* MSDC_DMA_CTRL mask */ | ||||
|  #define MSDC_DMA_CTRL_START     (0x1 << 0)	/* W */ | ||||
|  #define MSDC_DMA_CTRL_STOP      (0x1 << 1)	/* W */ | ||||
| @@ -217,6 +222,8 @@
 | ||||
|  #define MSDC_PATCH_BIT_SPCPUSH    (0x1 << 29)	/* RW */ | ||||
|  #define MSDC_PATCH_BIT_DECRCTMO   (0x1 << 30)	/* RW */ | ||||
|   | ||||
| +#define MSDC_PATCH_BIT1_STOP_DLY  (0xf << 8)    /* RW */
 | ||||
| +
 | ||||
|  #define MSDC_PATCH_BIT2_CFGRESP   (0x1 << 15)   /* RW */ | ||||
|  #define MSDC_PATCH_BIT2_CFGCRCSTS (0x1 << 28)   /* RW */ | ||||
|  #define MSDC_PB2_RESPWAIT         (0x3 << 2)    /* RW */ | ||||
| @@ -242,6 +249,9 @@
 | ||||
|  #define EMMC50_CFG_CRCSTS_EDGE    (0x1 << 3)   /* RW */ | ||||
|  #define EMMC50_CFG_CFCSTS_SEL     (0x1 << 4)   /* RW */ | ||||
|   | ||||
| +#define SDC_FIFO_CFG_WRVALIDSEL   (0x1 << 24)  /* RW */
 | ||||
| +#define SDC_FIFO_CFG_RDVALIDSEL   (0x1 << 25)  /* RW */
 | ||||
| +
 | ||||
|  #define REQ_CMD_EIO  (0x1 << 0) | ||||
|  #define REQ_CMD_TMO  (0x1 << 1) | ||||
|  #define REQ_DAT_ERR  (0x1 << 2) | ||||
| @@ -308,6 +318,7 @@ struct msdc_save_para {
 | ||||
|  	u32 pad_ds_tune; | ||||
|  	u32 pad_cmd_tune; | ||||
|  	u32 emmc50_cfg0; | ||||
| +	u32 sdc_fifo_cfg;
 | ||||
|  }; | ||||
|   | ||||
|  struct mtk_mmc_compatible { | ||||
| @@ -317,6 +328,8 @@ struct mtk_mmc_compatible {
 | ||||
|  	bool async_fifo; | ||||
|  	bool data_tune; | ||||
|  	bool busy_check; | ||||
| +	bool stop_clk_fix;
 | ||||
| +	bool enhance_rx;
 | ||||
|  }; | ||||
|   | ||||
|  struct msdc_tune_para { | ||||
| @@ -382,6 +395,8 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.async_fifo = false, | ||||
|  	.data_tune = false, | ||||
|  	.busy_check = false, | ||||
| +	.stop_clk_fix = false,
 | ||||
| +	.enhance_rx = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt8173_compat = { | ||||
| @@ -391,6 +406,8 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.async_fifo = false, | ||||
|  	.data_tune = false, | ||||
|  	.busy_check = false, | ||||
| +	.stop_clk_fix = false,
 | ||||
| +	.enhance_rx = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2701_compat = { | ||||
| @@ -400,6 +417,8 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.async_fifo = true, | ||||
|  	.data_tune = true, | ||||
|  	.busy_check = false, | ||||
| +	.stop_clk_fix = false,
 | ||||
| +	.enhance_rx = false,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_mmc_compatible mt2712_compat = { | ||||
| @@ -409,6 +428,8 @@ static const struct mtk_mmc_compatible m
 | ||||
|  	.async_fifo = true, | ||||
|  	.data_tune = true, | ||||
|  	.busy_check = true, | ||||
| +	.stop_clk_fix = true,
 | ||||
| +	.enhance_rx = true,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id msdc_of_ids[] = { | ||||
| @@ -1280,15 +1301,31 @@ static void msdc_init_hw(struct msdc_hos
 | ||||
|  	sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_CKGEN_MSDC_DLY_SEL, 1); | ||||
|  	writel(0xffff4089, host->base + MSDC_PATCH_BIT1); | ||||
|  	sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL); | ||||
| +
 | ||||
| +	if (host->dev_comp->stop_clk_fix) {
 | ||||
| +		sdr_set_field(host->base + MSDC_PATCH_BIT1,
 | ||||
| +			      MSDC_PATCH_BIT1_STOP_DLY, 3);
 | ||||
| +		sdr_clr_bits(host->base + SDC_FIFO_CFG,
 | ||||
| +			     SDC_FIFO_CFG_WRVALIDSEL);
 | ||||
| +		sdr_clr_bits(host->base + SDC_FIFO_CFG,
 | ||||
| +			     SDC_FIFO_CFG_RDVALIDSEL);
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	if (host->dev_comp->busy_check) | ||||
|  		sdr_clr_bits(host->base + MSDC_PATCH_BIT1, (1 << 7)); | ||||
| +
 | ||||
|  	if (host->dev_comp->async_fifo) { | ||||
|  		sdr_set_field(host->base + MSDC_PATCH_BIT2, | ||||
|  			      MSDC_PB2_RESPWAIT, 3); | ||||
| -		sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| -			      MSDC_PB2_RESPSTSENSEL, 2);
 | ||||
| -		sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| -			      MSDC_PB2_CRCSTSENSEL, 2);
 | ||||
| +		if (host->dev_comp->enhance_rx) {
 | ||||
| +			sdr_set_bits(host->base + SDC_ADV_CFG0,
 | ||||
| +				     SDC_RX_ENHANCE_EN);
 | ||||
| +		} else {
 | ||||
| +			sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| +				      MSDC_PB2_RESPSTSENSEL, 2);
 | ||||
| +			sdr_set_field(host->base + MSDC_PATCH_BIT2,
 | ||||
| +				      MSDC_PB2_CRCSTSENSEL, 2);
 | ||||
| +		}
 | ||||
|  		/* use async fifo, then no need tune internal delay */ | ||||
|  		sdr_clr_bits(host->base + MSDC_PATCH_BIT2, | ||||
|  			     MSDC_PATCH_BIT2_CFGRESP); | ||||
| @@ -1933,6 +1970,7 @@ static void msdc_save_reg(struct msdc_ho
 | ||||
|  	host->save_para.pad_ds_tune = readl(host->base + PAD_DS_TUNE); | ||||
|  	host->save_para.pad_cmd_tune = readl(host->base + PAD_CMD_TUNE); | ||||
|  	host->save_para.emmc50_cfg0 = readl(host->base + EMMC50_CFG0); | ||||
| +	host->save_para.sdc_fifo_cfg = readl(host->base + SDC_FIFO_CFG);
 | ||||
|  } | ||||
|   | ||||
|  static void msdc_restore_reg(struct msdc_host *host) | ||||
| @@ -1949,6 +1987,7 @@ static void msdc_restore_reg(struct msdc
 | ||||
|  	writel(host->save_para.pad_ds_tune, host->base + PAD_DS_TUNE); | ||||
|  	writel(host->save_para.pad_cmd_tune, host->base + PAD_CMD_TUNE); | ||||
|  	writel(host->save_para.emmc50_cfg0, host->base + EMMC50_CFG0); | ||||
| +	writel(host->save_para.sdc_fifo_cfg, host->base + SDC_FIFO_CFG);
 | ||||
|  } | ||||
|   | ||||
|  static int msdc_runtime_suspend(struct device *dev) | ||||
|  | @ -0,0 +1,85 @@ | |||
| From 3c6b94d7091f0793445f2faf777e584af643e9da Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:36 +0800 | ||||
| Subject: [PATCH 157/224] mmc: mediatek: add support of source_cg clock | ||||
| 
 | ||||
| source clock need an independent cg to control, when doing clk mode | ||||
| switch, need gate source clock to avoid hw issue(multi-bit sync hw hang) | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 23 ++++++++++++++++++++++- | ||||
|  1 file changed, 22 insertions(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -372,6 +372,7 @@ struct msdc_host {
 | ||||
|   | ||||
|  	struct clk *src_clk;	/* msdc source clock */ | ||||
|  	struct clk *h_clk;      /* msdc h_clk */ | ||||
| +	struct clk *src_clk_cg; /* msdc source clock control gate */
 | ||||
|  	u32 mclk;		/* mmc subsystem clock frequency */ | ||||
|  	u32 src_clk_freq;	/* source clock frequency */ | ||||
|  	u32 sclk;		/* SD/MS bus clock frequency */ | ||||
| @@ -616,6 +617,7 @@ static void msdc_set_timeout(struct msdc
 | ||||
|   | ||||
|  static void msdc_gate_clock(struct msdc_host *host) | ||||
|  { | ||||
| +	clk_disable_unprepare(host->src_clk_cg);
 | ||||
|  	clk_disable_unprepare(host->src_clk); | ||||
|  	clk_disable_unprepare(host->h_clk); | ||||
|  } | ||||
| @@ -624,6 +626,7 @@ static void msdc_ungate_clock(struct msd
 | ||||
|  { | ||||
|  	clk_prepare_enable(host->h_clk); | ||||
|  	clk_prepare_enable(host->src_clk); | ||||
| +	clk_prepare_enable(host->src_clk_cg);
 | ||||
|  	while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) | ||||
|  		cpu_relax(); | ||||
|  } | ||||
| @@ -692,6 +695,15 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  			sclk = (host->src_clk_freq >> 2) / div; | ||||
|  		} | ||||
|  	} | ||||
| +	sdr_clr_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN);
 | ||||
| +	/*
 | ||||
| +	 * As src_clk/HCLK use the same bit to gate/ungate,
 | ||||
| +	 * So if want to only gate src_clk, need gate its parent(mux).
 | ||||
| +	 */
 | ||||
| +	if (host->src_clk_cg)
 | ||||
| +		clk_disable_unprepare(host->src_clk_cg);
 | ||||
| +	else
 | ||||
| +		clk_disable_unprepare(clk_get_parent(host->src_clk));
 | ||||
|  	if (host->dev_comp->clk_div_bits == 8) | ||||
|  		sdr_set_field(host->base + MSDC_CFG, | ||||
|  			      MSDC_CFG_CKMOD | MSDC_CFG_CKDIV, | ||||
| @@ -700,10 +712,14 @@ static void msdc_set_mclk(struct msdc_ho
 | ||||
|  		sdr_set_field(host->base + MSDC_CFG, | ||||
|  			      MSDC_CFG_CKMOD_EXTRA | MSDC_CFG_CKDIV_EXTRA, | ||||
|  			      (mode << 12) | div); | ||||
| +	if (host->src_clk_cg)
 | ||||
| +		clk_prepare_enable(host->src_clk_cg);
 | ||||
| +	else
 | ||||
| +		clk_prepare_enable(clk_get_parent(host->src_clk));
 | ||||
|   | ||||
| -	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN);
 | ||||
|  	while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) | ||||
|  		cpu_relax(); | ||||
| +	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN);
 | ||||
|  	host->sclk = sclk; | ||||
|  	host->mclk = hz; | ||||
|  	host->timing = timing; | ||||
| @@ -1822,6 +1838,11 @@ static int msdc_drv_probe(struct platfor
 | ||||
|  		goto host_free; | ||||
|  	} | ||||
|   | ||||
| +	/*source clock control gate is optional clock*/
 | ||||
| +	host->src_clk_cg = devm_clk_get(&pdev->dev, "source_cg");
 | ||||
| +	if (IS_ERR(host->src_clk_cg))
 | ||||
| +		host->src_clk_cg = NULL;
 | ||||
| +
 | ||||
|  	host->irq = platform_get_irq(pdev, 0); | ||||
|  	if (host->irq < 0) { | ||||
|  		ret = -EINVAL; | ||||
|  | @ -0,0 +1,45 @@ | |||
| From de14d1d0dc7ecf5c3e7e2a591b4f14e688fa52e6 Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:37 +0800 | ||||
| Subject: [PATCH 158/224] mmc: mediatek: add latch-ck support | ||||
| 
 | ||||
| some platform(eg.mt2701) does not support "stop clk fix", in | ||||
| this case, need set correct latch-ck to avoid crc error caused | ||||
| by stop clock block-internally. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 6 ++++++ | ||||
|  1 file changed, 6 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -378,6 +378,7 @@ struct msdc_host {
 | ||||
|  	u32 sclk;		/* SD/MS bus clock frequency */ | ||||
|  	unsigned char timing; | ||||
|  	bool vqmmc_enabled; | ||||
| +	u32 latch_ck;
 | ||||
|  	u32 hs400_ds_delay; | ||||
|  	u32 hs200_cmd_int_delay; /* cmd internal delay for HS200/SDR104 */ | ||||
|  	u32 hs400_cmd_int_delay; /* cmd internal delay for HS400 */ | ||||
| @@ -1661,6 +1662,8 @@ static int msdc_tune_data(struct mmc_hos
 | ||||
|  	u32 tune_reg = host->dev_comp->pad_tune_reg; | ||||
|  	int i, ret; | ||||
|   | ||||
| +	sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_INT_DAT_LATCH_CK_SEL,
 | ||||
| +		      host->latch_ck);
 | ||||
|  	sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_DSPL); | ||||
|  	sdr_clr_bits(host->base + MSDC_IOCON, MSDC_IOCON_W_DSPL); | ||||
|  	for (i = 0 ; i < PAD_DELAY_MAX; i++) { | ||||
| @@ -1773,6 +1776,9 @@ static const struct mmc_host_ops mt_msdc
 | ||||
|  static void msdc_of_property_parse(struct platform_device *pdev, | ||||
|  				   struct msdc_host *host) | ||||
|  { | ||||
| +	of_property_read_u32(pdev->dev.of_node, "mediatek,latch-ck",
 | ||||
| +			     &host->latch_ck);
 | ||||
| +
 | ||||
|  	of_property_read_u32(pdev->dev.of_node, "hs400-ds-delay", | ||||
|  			     &host->hs400_ds_delay); | ||||
|   | ||||
|  | @ -0,0 +1,68 @@ | |||
| From 29e154716049310bb8c559f742bf2b460d5b6bbc Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:38 +0800 | ||||
| Subject: [PATCH 159/224] mmc: mediatek: improve eMMC hs400 mode read | ||||
|  performance | ||||
| 
 | ||||
| enlarge outstanding value to improve read performance | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 9 +++++++++ | ||||
|  1 file changed, 9 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -81,6 +81,7 @@
 | ||||
|  #define PAD_DS_TUNE      0x188 | ||||
|  #define PAD_CMD_TUNE     0x18c | ||||
|  #define EMMC50_CFG0      0x208 | ||||
| +#define EMMC50_CFG3      0x220
 | ||||
|  #define SDC_FIFO_CFG     0x228 | ||||
|   | ||||
|  /*--------------------------------------------------------------------------*/ | ||||
| @@ -249,6 +250,8 @@
 | ||||
|  #define EMMC50_CFG_CRCSTS_EDGE    (0x1 << 3)   /* RW */ | ||||
|  #define EMMC50_CFG_CFCSTS_SEL     (0x1 << 4)   /* RW */ | ||||
|   | ||||
| +#define EMMC50_CFG3_OUTS_WR       (0x1f << 0)  /* RW */
 | ||||
| +
 | ||||
|  #define SDC_FIFO_CFG_WRVALIDSEL   (0x1 << 24)  /* RW */ | ||||
|  #define SDC_FIFO_CFG_RDVALIDSEL   (0x1 << 25)  /* RW */ | ||||
|   | ||||
| @@ -318,6 +321,7 @@ struct msdc_save_para {
 | ||||
|  	u32 pad_ds_tune; | ||||
|  	u32 pad_cmd_tune; | ||||
|  	u32 emmc50_cfg0; | ||||
| +	u32 emmc50_cfg3;
 | ||||
|  	u32 sdc_fifo_cfg; | ||||
|  }; | ||||
|   | ||||
| @@ -1747,6 +1751,9 @@ static int msdc_prepare_hs400_tuning(str
 | ||||
|  	writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE); | ||||
|  	/* hs400 mode must set it to 0 */ | ||||
|  	sdr_clr_bits(host->base + MSDC_PATCH_BIT2, MSDC_PATCH_BIT2_CFGCRCSTS); | ||||
| +	/* to improve read performance, set outstanding to 2 */
 | ||||
| +	sdr_set_field(host->base + EMMC50_CFG3, EMMC50_CFG3_OUTS_WR, 2);
 | ||||
| +
 | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| @@ -1997,6 +2004,7 @@ static void msdc_save_reg(struct msdc_ho
 | ||||
|  	host->save_para.pad_ds_tune = readl(host->base + PAD_DS_TUNE); | ||||
|  	host->save_para.pad_cmd_tune = readl(host->base + PAD_CMD_TUNE); | ||||
|  	host->save_para.emmc50_cfg0 = readl(host->base + EMMC50_CFG0); | ||||
| +	host->save_para.emmc50_cfg3 = readl(host->base + EMMC50_CFG3);
 | ||||
|  	host->save_para.sdc_fifo_cfg = readl(host->base + SDC_FIFO_CFG); | ||||
|  } | ||||
|   | ||||
| @@ -2014,6 +2022,7 @@ static void msdc_restore_reg(struct msdc
 | ||||
|  	writel(host->save_para.pad_ds_tune, host->base + PAD_DS_TUNE); | ||||
|  	writel(host->save_para.pad_cmd_tune, host->base + PAD_CMD_TUNE); | ||||
|  	writel(host->save_para.emmc50_cfg0, host->base + EMMC50_CFG0); | ||||
| +	writel(host->save_para.emmc50_cfg3, host->base + EMMC50_CFG3);
 | ||||
|  	writel(host->save_para.sdc_fifo_cfg, host->base + SDC_FIFO_CFG); | ||||
|  } | ||||
|   | ||||
|  | @ -0,0 +1,28 @@ | |||
| From 81fdc4983e33ef01935a9bf01187951aad34e2ac Mon Sep 17 00:00:00 2001 | ||||
| From: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Date: Mon, 16 Oct 2017 09:46:39 +0800 | ||||
| Subject: [PATCH 160/224] mmc: mediatek: perfer to use rise edge latching for | ||||
|  cmd line | ||||
| 
 | ||||
| data lines have applied to perfer to use rise edge, also need | ||||
| apply it to cmd line. | ||||
| 
 | ||||
| Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> | ||||
| Tested-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  drivers/mmc/host/mtk-sd.c | 3 ++- | ||||
|  1 file changed, 2 insertions(+), 1 deletion(-) | ||||
| 
 | ||||
| --- a/drivers/mmc/host/mtk-sd.c
 | ||||
| +++ b/drivers/mmc/host/mtk-sd.c
 | ||||
| @@ -1550,7 +1550,8 @@ static int msdc_tune_response(struct mmc
 | ||||
|  	} | ||||
|  	final_rise_delay = get_best_delay(host, rise_delay); | ||||
|  	/* if rising edge has enough margin, then do not scan falling edge */ | ||||
| -	if (final_rise_delay.maxlen >= 12 && final_rise_delay.start < 4)
 | ||||
| +	if (final_rise_delay.maxlen >= 12 ||
 | ||||
| +	    (final_rise_delay.start == 0 && final_rise_delay.maxlen >= 4))
 | ||||
|  		goto skip_fall; | ||||
|   | ||||
|  	sdr_set_bits(host->base + MSDC_IOCON, MSDC_IOCON_RSPL); | ||||
|  | @ -0,0 +1,145 @@ | |||
| From 7cc8226e45b2c6b9f06ce82ba6995b8f911afe25 Mon Sep 17 00:00:00 2001 | ||||
| From: Zhi Mao <zhi.mao@mediatek.com> | ||||
| Date: Wed, 25 Oct 2017 18:11:01 +0800 | ||||
| Subject: [PATCH 161/224] pwm: mediatek: Add MT2712/MT7622 support | ||||
| 
 | ||||
| Add support for MT2712 and MT7622. Due to register offset address of | ||||
| pwm7 for MT2712 is not fixed 0x40, add mtk_pwm_reg_offset array for PWM | ||||
| register offset. | ||||
| 
 | ||||
| Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Zhi Mao <zhi.mao@mediatek.com> | ||||
| Signed-off-by: Thierry Reding <thierry.reding@gmail.com> | ||||
| ---
 | ||||
|  drivers/pwm/pwm-mediatek.c | 53 ++++++++++++++++++++++++++++++++++++++-------- | ||||
|  1 file changed, 44 insertions(+), 9 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/pwm/pwm-mediatek.c
 | ||||
| +++ b/drivers/pwm/pwm-mediatek.c
 | ||||
| @@ -16,6 +16,7 @@
 | ||||
|  #include <linux/module.h> | ||||
|  #include <linux/clk.h> | ||||
|  #include <linux/of.h> | ||||
| +#include <linux/of_device.h>
 | ||||
|  #include <linux/platform_device.h> | ||||
|  #include <linux/pwm.h> | ||||
|  #include <linux/slab.h> | ||||
| @@ -40,11 +41,19 @@ enum {
 | ||||
|  	MTK_CLK_PWM3, | ||||
|  	MTK_CLK_PWM4, | ||||
|  	MTK_CLK_PWM5, | ||||
| +	MTK_CLK_PWM6,
 | ||||
| +	MTK_CLK_PWM7,
 | ||||
| +	MTK_CLK_PWM8,
 | ||||
|  	MTK_CLK_MAX, | ||||
|  }; | ||||
|   | ||||
| -static const char * const mtk_pwm_clk_name[] = {
 | ||||
| -	"main", "top", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5"
 | ||||
| +static const char * const mtk_pwm_clk_name[MTK_CLK_MAX] = {
 | ||||
| +	"main", "top", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5", "pwm6", "pwm7",
 | ||||
| +	"pwm8"
 | ||||
| +};
 | ||||
| +
 | ||||
| +struct mtk_pwm_platform_data {
 | ||||
| +	unsigned int num_pwms;
 | ||||
|  }; | ||||
|   | ||||
|  /** | ||||
| @@ -59,6 +68,10 @@ struct mtk_pwm_chip {
 | ||||
|  	struct clk *clks[MTK_CLK_MAX]; | ||||
|  }; | ||||
|   | ||||
| +static const unsigned int mtk_pwm_reg_offset[] = {
 | ||||
| +	0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220
 | ||||
| +};
 | ||||
| +
 | ||||
|  static inline struct mtk_pwm_chip *to_mtk_pwm_chip(struct pwm_chip *chip) | ||||
|  { | ||||
|  	return container_of(chip, struct mtk_pwm_chip, chip); | ||||
| @@ -103,14 +116,14 @@ static void mtk_pwm_clk_disable(struct p
 | ||||
|  static inline u32 mtk_pwm_readl(struct mtk_pwm_chip *chip, unsigned int num, | ||||
|  				unsigned int offset) | ||||
|  { | ||||
| -	return readl(chip->regs + 0x10 + (num * 0x40) + offset);
 | ||||
| +	return readl(chip->regs + mtk_pwm_reg_offset[num] + offset);
 | ||||
|  } | ||||
|   | ||||
|  static inline void mtk_pwm_writel(struct mtk_pwm_chip *chip, | ||||
|  				  unsigned int num, unsigned int offset, | ||||
|  				  u32 value) | ||||
|  { | ||||
| -	writel(value, chip->regs + 0x10 + (num * 0x40) + offset);
 | ||||
| +	writel(value, chip->regs + mtk_pwm_reg_offset[num] + offset);
 | ||||
|  } | ||||
|   | ||||
|  static int mtk_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | ||||
| @@ -185,6 +198,7 @@ static const struct pwm_ops mtk_pwm_ops
 | ||||
|   | ||||
|  static int mtk_pwm_probe(struct platform_device *pdev) | ||||
|  { | ||||
| +	const struct mtk_pwm_platform_data *data;
 | ||||
|  	struct mtk_pwm_chip *pc; | ||||
|  	struct resource *res; | ||||
|  	unsigned int i; | ||||
| @@ -194,15 +208,22 @@ static int mtk_pwm_probe(struct platform
 | ||||
|  	if (!pc) | ||||
|  		return -ENOMEM; | ||||
|   | ||||
| +	data = of_device_get_match_data(&pdev->dev);
 | ||||
| +	if (data == NULL)
 | ||||
| +		return -EINVAL;
 | ||||
| +
 | ||||
|  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||||
|  	pc->regs = devm_ioremap_resource(&pdev->dev, res); | ||||
|  	if (IS_ERR(pc->regs)) | ||||
|  		return PTR_ERR(pc->regs); | ||||
|   | ||||
| -	for (i = 0; i < MTK_CLK_MAX; i++) {
 | ||||
| +	for (i = 0; i < data->num_pwms + 2; i++) {
 | ||||
|  		pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); | ||||
| -		if (IS_ERR(pc->clks[i]))
 | ||||
| +		if (IS_ERR(pc->clks[i])) {
 | ||||
| +			dev_err(&pdev->dev, "clock: %s fail: %ld\n",
 | ||||
| +				mtk_pwm_clk_name[i], PTR_ERR(pc->clks[i]));
 | ||||
|  			return PTR_ERR(pc->clks[i]); | ||||
| +		}
 | ||||
|  	} | ||||
|   | ||||
|  	platform_set_drvdata(pdev, pc); | ||||
| @@ -210,7 +231,7 @@ static int mtk_pwm_probe(struct platform
 | ||||
|  	pc->chip.dev = &pdev->dev; | ||||
|  	pc->chip.ops = &mtk_pwm_ops; | ||||
|  	pc->chip.base = -1; | ||||
| -	pc->chip.npwm = 5;
 | ||||
| +	pc->chip.npwm = data->num_pwms;
 | ||||
|   | ||||
|  	ret = pwmchip_add(&pc->chip); | ||||
|  	if (ret < 0) { | ||||
| @@ -228,9 +249,23 @@ static int mtk_pwm_remove(struct platfor
 | ||||
|  	return pwmchip_remove(&pc->chip); | ||||
|  } | ||||
|   | ||||
| +static const struct mtk_pwm_platform_data mt2712_pwm_data = {
 | ||||
| +	.num_pwms = 8,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct mtk_pwm_platform_data mt7622_pwm_data = {
 | ||||
| +	.num_pwms = 6,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static const struct mtk_pwm_platform_data mt7623_pwm_data = {
 | ||||
| +	.num_pwms = 5,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static const struct of_device_id mtk_pwm_of_match[] = { | ||||
| -	{ .compatible = "mediatek,mt7623-pwm" },
 | ||||
| -	{ }
 | ||||
| +	{ .compatible = "mediatek,mt2712-pwm", .data = &mt2712_pwm_data },
 | ||||
| +	{ .compatible = "mediatek,mt7622-pwm", .data = &mt7622_pwm_data },
 | ||||
| +	{ .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data },
 | ||||
| +	{ },
 | ||||
|  }; | ||||
|  MODULE_DEVICE_TABLE(of, mtk_pwm_of_match); | ||||
|   | ||||
|  | @ -0,0 +1,41 @@ | |||
| From fb607c7c1eaeb47ec2ffed99cab571892cb6af7d Mon Sep 17 00:00:00 2001 | ||||
| From: Xiaolei Li <xiaolei.li@mediatek.com> | ||||
| Date: Thu, 2 Nov 2017 10:05:07 +0800 | ||||
| Subject: [PATCH 162/224] mtd: nand: mtk: use nand_reset() to reset NAND | ||||
|  devices in resume function | ||||
| 
 | ||||
| Previously, we only select chips and then send reset command to a NAND | ||||
| device during resuming nand driver. There is a lack of deselecting chips. | ||||
| It is advised to reset and initialize a NAND device using nand_reset(). | ||||
| 
 | ||||
| Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/mtd/nand/mtk_nand.c | 8 ++------ | ||||
|  1 file changed, 2 insertions(+), 6 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mtd/nand/mtk_nand.c
 | ||||
| +++ b/drivers/mtd/nand/mtk_nand.c
 | ||||
| @@ -1540,7 +1540,6 @@ static int mtk_nfc_resume(struct device
 | ||||
|  	struct mtk_nfc *nfc = dev_get_drvdata(dev); | ||||
|  	struct mtk_nfc_nand_chip *chip; | ||||
|  	struct nand_chip *nand; | ||||
| -	struct mtd_info *mtd;
 | ||||
|  	int ret; | ||||
|  	u32 i; | ||||
|   | ||||
| @@ -1553,11 +1552,8 @@ static int mtk_nfc_resume(struct device
 | ||||
|  	/* reset NAND chip if VCC was powered off */ | ||||
|  	list_for_each_entry(chip, &nfc->chips, node) { | ||||
|  		nand = &chip->nand; | ||||
| -		mtd = nand_to_mtd(nand);
 | ||||
| -		for (i = 0; i < chip->nsels; i++) {
 | ||||
| -			nand->select_chip(mtd, i);
 | ||||
| -			nand->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
 | ||||
| -		}
 | ||||
| +		for (i = 0; i < chip->nsels; i++)
 | ||||
| +			nand_reset(nand, i);
 | ||||
|  	} | ||||
|   | ||||
|  	return 0; | ||||
|  | @ -0,0 +1,24 @@ | |||
| From f027d8b7248cef5b3d3eb8ac68e1040fba340995 Mon Sep 17 00:00:00 2001 | ||||
| From: Andrew-sh Cheng <andrew-sh.cheng@mediatek.com> | ||||
| Date: Fri, 8 Dec 2017 14:07:55 +0800 | ||||
| Subject: [PATCH 164/224] cpufreq: mediatek: add mt2712 into compatible list | ||||
| 
 | ||||
| Support mt2712 in mediatek-cpufreq.c | ||||
| 
 | ||||
| Signed-off-by: Andrew-sh Cheng <andrew-sh.cheng@mediatek.com> | ||||
| Acked-by: Viresh Kumar <viresh.kumar@linaro.org> | ||||
| Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||||
| ---
 | ||||
|  drivers/cpufreq/mediatek-cpufreq.c | 1 + | ||||
|  1 file changed, 1 insertion(+) | ||||
| 
 | ||||
| --- a/drivers/cpufreq/mediatek-cpufreq.c
 | ||||
| +++ b/drivers/cpufreq/mediatek-cpufreq.c
 | ||||
| @@ -574,6 +574,7 @@ static struct platform_driver mtk_cpufre
 | ||||
|  /* List of machines supported by this driver */ | ||||
|  static const struct of_device_id mtk_cpufreq_machines[] __initconst = { | ||||
|  	{ .compatible = "mediatek,mt2701", }, | ||||
| +	{ .compatible = "mediatek,mt2712", },
 | ||||
|  	{ .compatible = "mediatek,mt7622", }, | ||||
|  	{ .compatible = "mediatek,mt7623", }, | ||||
|  	{ .compatible = "mediatek,mt817x", }, | ||||
|  | @ -0,0 +1,41 @@ | |||
| From 42611c6d9f12d16ce4247d76b16218e54ef5b949 Mon Sep 17 00:00:00 2001 | ||||
| From: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Date: Thu, 30 Nov 2017 22:10:43 +0800 | ||||
| Subject: [PATCH 165/224] mtd: nand: mtk: update DT bindings | ||||
| 
 | ||||
| Add MT7622 NAND Flash Controller dt bindings documentation. | ||||
| 
 | ||||
| Signed-off-by: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> | ||||
| Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/mtd/mtk-nand.txt | 11 ++++++++--- | ||||
|  1 file changed, 8 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/mtd/mtk-nand.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/mtd/mtk-nand.txt
 | ||||
| @@ -12,8 +12,10 @@ tree nodes.
 | ||||
|   | ||||
|  The first part of NFC is NAND Controller Interface (NFI) HW. | ||||
|  Required NFI properties: | ||||
| -- compatible:			Should be one of "mediatek,mt2701-nfc",
 | ||||
| -				"mediatek,mt2712-nfc".
 | ||||
| +- compatible:			Should be one of
 | ||||
| +				"mediatek,mt2701-nfc",
 | ||||
| +				"mediatek,mt2712-nfc",
 | ||||
| +				"mediatek,mt7622-nfc".
 | ||||
|  - reg:				Base physical address and size of NFI. | ||||
|  - interrupts:			Interrupts of NFI. | ||||
|  - clocks:			NFI required clocks. | ||||
| @@ -142,7 +144,10 @@ Example:
 | ||||
|  ============== | ||||
|   | ||||
|  Required BCH properties: | ||||
| -- compatible:	Should be one of "mediatek,mt2701-ecc", "mediatek,mt2712-ecc".
 | ||||
| +- compatible:	Should be one of
 | ||||
| +		"mediatek,mt2701-ecc",
 | ||||
| +		"mediatek,mt2712-ecc",
 | ||||
| +		"mediatek,mt7622-ecc".
 | ||||
|  - reg:		Base physical address and size of ECC. | ||||
|  - interrupts:	Interrupts of ECC. | ||||
|  - clocks:	ECC required clocks. | ||||
|  | @ -0,0 +1,380 @@ | |||
| From fd1a1eabf2473e769b5cafc704e0336d11f61961 Mon Sep 17 00:00:00 2001 | ||||
| From: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Date: Thu, 30 Nov 2017 22:10:44 +0800 | ||||
| Subject: [PATCH 166/224] mtd: nand: mtk: Support different MTK NAND flash | ||||
|  controller IP | ||||
| 
 | ||||
| MT7622 uses an MTK's earlier NAND flash controller IP which support | ||||
| different sector size, max spare size per sector and paraity bits...,
 | ||||
| some register's offset and definition also been changed in the NAND | ||||
| flash controller, this patch is the preparation to support MT7622 | ||||
| NAND flash controller. | ||||
| 
 | ||||
| MT7622 NFC and ECC engine are similar to MT2701's, except below | ||||
| differences:
 | ||||
| (1)MT7622 NFC's max sector size(ECC data size) is 512 bytes, and | ||||
|    MT2701's is 1024, and MT7622's max sector number is 8. | ||||
| (2)The parity bit of MT7622 is 13, MT2701 is 14. | ||||
| (3)MT7622 ECC supports less ECC strength, max to 16 bit ecc strength. | ||||
| (4)MT7622 supports less spare size per sector, max spare size per | ||||
|    sector is 28 bytes. | ||||
| (5)Some register's offset are different, include ECC_ENCIRQ_EN, | ||||
|    ECC_ENCIRQ_STA, ECC_DECDONE, ECC_DECIRQ_EN and ECC_DECIRQ_STA. | ||||
| (6)ENC_MODE of ECC_ENCCNFG register is moved from bit 5-6 to bit 4-5. | ||||
| 
 | ||||
| Signed-off-by: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/mtd/nand/mtk_ecc.c  | 100 ++++++++++++++++++++++++++++++-------------- | ||||
|  drivers/mtd/nand/mtk_ecc.h  |   3 +- | ||||
|  drivers/mtd/nand/mtk_nand.c |  27 ++++++++---- | ||||
|  3 files changed, 89 insertions(+), 41 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/mtd/nand/mtk_ecc.c
 | ||||
| +++ b/drivers/mtd/nand/mtk_ecc.c
 | ||||
| @@ -34,34 +34,28 @@
 | ||||
|   | ||||
|  #define ECC_ENCCON		(0x00) | ||||
|  #define ECC_ENCCNFG		(0x04) | ||||
| -#define		ECC_MODE_SHIFT		(5)
 | ||||
|  #define		ECC_MS_SHIFT		(16) | ||||
|  #define ECC_ENCDIADDR		(0x08) | ||||
|  #define ECC_ENCIDLE		(0x0C) | ||||
| -#define ECC_ENCIRQ_EN		(0x80)
 | ||||
| -#define ECC_ENCIRQ_STA		(0x84)
 | ||||
|  #define ECC_DECCON		(0x100) | ||||
|  #define ECC_DECCNFG		(0x104) | ||||
|  #define		DEC_EMPTY_EN		BIT(31) | ||||
|  #define		DEC_CNFG_CORRECT	(0x3 << 12) | ||||
|  #define ECC_DECIDLE		(0x10C) | ||||
|  #define ECC_DECENUM0		(0x114) | ||||
| -#define ECC_DECDONE		(0x124)
 | ||||
| -#define ECC_DECIRQ_EN		(0x200)
 | ||||
| -#define ECC_DECIRQ_STA		(0x204)
 | ||||
|   | ||||
|  #define ECC_TIMEOUT		(500000) | ||||
|   | ||||
|  #define ECC_IDLE_REG(op)	((op) == ECC_ENCODE ? ECC_ENCIDLE : ECC_DECIDLE) | ||||
|  #define ECC_CTL_REG(op)		((op) == ECC_ENCODE ? ECC_ENCCON : ECC_DECCON) | ||||
| -#define ECC_IRQ_REG(op)		((op) == ECC_ENCODE ? \
 | ||||
| -					ECC_ENCIRQ_EN : ECC_DECIRQ_EN)
 | ||||
|   | ||||
|  struct mtk_ecc_caps { | ||||
|  	u32 err_mask; | ||||
|  	const u8 *ecc_strength; | ||||
| +	const u32 *ecc_regs;
 | ||||
|  	u8 num_ecc_strength; | ||||
| -	u32 encode_parity_reg0;
 | ||||
| +	u8 ecc_mode_shift;
 | ||||
| +	u32 parity_bits;
 | ||||
|  	int pg_irq_sel; | ||||
|  }; | ||||
|   | ||||
| @@ -89,6 +83,33 @@ static const u8 ecc_strength_mt2712[] =
 | ||||
|  	40, 44, 48, 52, 56, 60, 68, 72, 80 | ||||
|  }; | ||||
|   | ||||
| +enum mtk_ecc_regs {
 | ||||
| +	ECC_ENCPAR00,
 | ||||
| +	ECC_ENCIRQ_EN,
 | ||||
| +	ECC_ENCIRQ_STA,
 | ||||
| +	ECC_DECDONE,
 | ||||
| +	ECC_DECIRQ_EN,
 | ||||
| +	ECC_DECIRQ_STA,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static int mt2701_ecc_regs[] = {
 | ||||
| +	[ECC_ENCPAR00] =        0x10,
 | ||||
| +	[ECC_ENCIRQ_EN] =       0x80,
 | ||||
| +	[ECC_ENCIRQ_STA] =      0x84,
 | ||||
| +	[ECC_DECDONE] =         0x124,
 | ||||
| +	[ECC_DECIRQ_EN] =       0x200,
 | ||||
| +	[ECC_DECIRQ_STA] =      0x204,
 | ||||
| +};
 | ||||
| +
 | ||||
| +static int mt2712_ecc_regs[] = {
 | ||||
| +	[ECC_ENCPAR00] =        0x300,
 | ||||
| +	[ECC_ENCIRQ_EN] =       0x80,
 | ||||
| +	[ECC_ENCIRQ_STA] =      0x84,
 | ||||
| +	[ECC_DECDONE] =         0x124,
 | ||||
| +	[ECC_DECIRQ_EN] =       0x200,
 | ||||
| +	[ECC_DECIRQ_STA] =      0x204,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc, | ||||
|  				     enum mtk_ecc_operation op) | ||||
|  { | ||||
| @@ -107,32 +128,30 @@ static inline void mtk_ecc_wait_idle(str
 | ||||
|  static irqreturn_t mtk_ecc_irq(int irq, void *id) | ||||
|  { | ||||
|  	struct mtk_ecc *ecc = id; | ||||
| -	enum mtk_ecc_operation op;
 | ||||
|  	u32 dec, enc; | ||||
|   | ||||
| -	dec = readw(ecc->regs + ECC_DECIRQ_STA) & ECC_IRQ_EN;
 | ||||
| +	dec = readw(ecc->regs + ecc->caps->ecc_regs[ECC_DECIRQ_STA])
 | ||||
| +		    & ECC_IRQ_EN;
 | ||||
|  	if (dec) { | ||||
| -		op = ECC_DECODE;
 | ||||
| -		dec = readw(ecc->regs + ECC_DECDONE);
 | ||||
| +		dec = readw(ecc->regs + ecc->caps->ecc_regs[ECC_DECDONE]);
 | ||||
|  		if (dec & ecc->sectors) { | ||||
|  			/* | ||||
|  			 * Clear decode IRQ status once again to ensure that | ||||
|  			 * there will be no extra IRQ. | ||||
|  			 */ | ||||
| -			readw(ecc->regs + ECC_DECIRQ_STA);
 | ||||
| +			readw(ecc->regs + ecc->caps->ecc_regs[ECC_DECIRQ_STA]);
 | ||||
|  			ecc->sectors = 0; | ||||
|  			complete(&ecc->done); | ||||
|  		} else { | ||||
|  			return IRQ_HANDLED; | ||||
|  		} | ||||
|  	} else { | ||||
| -		enc = readl(ecc->regs + ECC_ENCIRQ_STA) & ECC_IRQ_EN;
 | ||||
| -		if (enc) {
 | ||||
| -			op = ECC_ENCODE;
 | ||||
| +		enc = readl(ecc->regs + ecc->caps->ecc_regs[ECC_ENCIRQ_STA])
 | ||||
| +		      & ECC_IRQ_EN;
 | ||||
| +		if (enc)
 | ||||
|  			complete(&ecc->done); | ||||
| -		} else {
 | ||||
| +		else
 | ||||
|  			return IRQ_NONE; | ||||
| -		}
 | ||||
|  	} | ||||
|   | ||||
|  	return IRQ_HANDLED; | ||||
| @@ -160,7 +179,7 @@ static int mtk_ecc_config(struct mtk_ecc
 | ||||
|  		/* configure ECC encoder (in bits) */ | ||||
|  		enc_sz = config->len << 3; | ||||
|   | ||||
| -		reg = ecc_bit | (config->mode << ECC_MODE_SHIFT);
 | ||||
| +		reg = ecc_bit | (config->mode << ecc->caps->ecc_mode_shift);
 | ||||
|  		reg |= (enc_sz << ECC_MS_SHIFT); | ||||
|  		writel(reg, ecc->regs + ECC_ENCCNFG); | ||||
|   | ||||
| @@ -171,9 +190,9 @@ static int mtk_ecc_config(struct mtk_ecc
 | ||||
|  	} else { | ||||
|  		/* configure ECC decoder (in bits) */ | ||||
|  		dec_sz = (config->len << 3) + | ||||
| -					config->strength * ECC_PARITY_BITS;
 | ||||
| +			 config->strength * ecc->caps->parity_bits;
 | ||||
|   | ||||
| -		reg = ecc_bit | (config->mode << ECC_MODE_SHIFT);
 | ||||
| +		reg = ecc_bit | (config->mode << ecc->caps->ecc_mode_shift);
 | ||||
|  		reg |= (dec_sz << ECC_MS_SHIFT) | DEC_CNFG_CORRECT; | ||||
|  		reg |= DEC_EMPTY_EN; | ||||
|  		writel(reg, ecc->regs + ECC_DECCNFG); | ||||
| @@ -291,7 +310,12 @@ int mtk_ecc_enable(struct mtk_ecc *ecc,
 | ||||
|  		 */ | ||||
|  		if (ecc->caps->pg_irq_sel && config->mode == ECC_NFI_MODE) | ||||
|  			reg_val |= ECC_PG_IRQ_SEL; | ||||
| -		writew(reg_val, ecc->regs + ECC_IRQ_REG(op));
 | ||||
| +		if (op == ECC_ENCODE)
 | ||||
| +			writew(reg_val, ecc->regs +
 | ||||
| +			       ecc->caps->ecc_regs[ECC_ENCIRQ_EN]);
 | ||||
| +		else
 | ||||
| +			writew(reg_val, ecc->regs +
 | ||||
| +			       ecc->caps->ecc_regs[ECC_DECIRQ_EN]);
 | ||||
|  	} | ||||
|   | ||||
|  	writew(ECC_OP_ENABLE, ecc->regs + ECC_CTL_REG(op)); | ||||
| @@ -310,13 +334,17 @@ void mtk_ecc_disable(struct mtk_ecc *ecc
 | ||||
|   | ||||
|  	/* disable it */ | ||||
|  	mtk_ecc_wait_idle(ecc, op); | ||||
| -	if (op == ECC_DECODE)
 | ||||
| +	if (op == ECC_DECODE) {
 | ||||
|  		/* | ||||
|  		 * Clear decode IRQ status in case there is a timeout to wait | ||||
|  		 * decode IRQ. | ||||
|  		 */ | ||||
| -		readw(ecc->regs + ECC_DECIRQ_STA);
 | ||||
| -	writew(0, ecc->regs + ECC_IRQ_REG(op));
 | ||||
| +		readw(ecc->regs + ecc->caps->ecc_regs[ECC_DECDONE]);
 | ||||
| +		writew(0, ecc->regs + ecc->caps->ecc_regs[ECC_DECIRQ_EN]);
 | ||||
| +	} else {
 | ||||
| +		writew(0, ecc->regs + ecc->caps->ecc_regs[ECC_ENCIRQ_EN]);
 | ||||
| +	}
 | ||||
| +
 | ||||
|  	writew(ECC_OP_DISABLE, ecc->regs + ECC_CTL_REG(op)); | ||||
|   | ||||
|  	mutex_unlock(&ecc->lock); | ||||
| @@ -367,11 +395,11 @@ int mtk_ecc_encode(struct mtk_ecc *ecc,
 | ||||
|  	mtk_ecc_wait_idle(ecc, ECC_ENCODE); | ||||
|   | ||||
|  	/* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */ | ||||
| -	len = (config->strength * ECC_PARITY_BITS + 7) >> 3;
 | ||||
| +	len = (config->strength * ecc->caps->parity_bits + 7) >> 3;
 | ||||
|   | ||||
|  	/* write the parity bytes generated by the ECC back to temp buffer */ | ||||
|  	__ioread32_copy(ecc->eccdata, | ||||
| -			ecc->regs + ecc->caps->encode_parity_reg0,
 | ||||
| +			ecc->regs + ecc->caps->ecc_regs[ECC_ENCPAR00],
 | ||||
|  			round_up(len, 4)); | ||||
|   | ||||
|  	/* copy into possibly unaligned OOB region with actual length */ | ||||
| @@ -404,19 +432,29 @@ void mtk_ecc_adjust_strength(struct mtk_
 | ||||
|  } | ||||
|  EXPORT_SYMBOL(mtk_ecc_adjust_strength); | ||||
|   | ||||
| +unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc)
 | ||||
| +{
 | ||||
| +	return ecc->caps->parity_bits;
 | ||||
| +}
 | ||||
| +EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
 | ||||
| +
 | ||||
|  static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = { | ||||
|  	.err_mask = 0x3f, | ||||
|  	.ecc_strength = ecc_strength_mt2701, | ||||
| +	.ecc_regs = mt2701_ecc_regs,
 | ||||
|  	.num_ecc_strength = 20, | ||||
| -	.encode_parity_reg0 = 0x10,
 | ||||
| +	.ecc_mode_shift = 5,
 | ||||
| +	.parity_bits = 14,
 | ||||
|  	.pg_irq_sel = 0, | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = { | ||||
|  	.err_mask = 0x7f, | ||||
|  	.ecc_strength = ecc_strength_mt2712, | ||||
| +	.ecc_regs = mt2712_ecc_regs,
 | ||||
|  	.num_ecc_strength = 23, | ||||
| -	.encode_parity_reg0 = 0x300,
 | ||||
| +	.ecc_mode_shift = 5,
 | ||||
| +	.parity_bits = 14,
 | ||||
|  	.pg_irq_sel = 1, | ||||
|  }; | ||||
|   | ||||
| @@ -452,7 +490,7 @@ static int mtk_ecc_probe(struct platform
 | ||||
|   | ||||
|  	max_eccdata_size = ecc->caps->num_ecc_strength - 1; | ||||
|  	max_eccdata_size = ecc->caps->ecc_strength[max_eccdata_size]; | ||||
| -	max_eccdata_size = (max_eccdata_size * ECC_PARITY_BITS + 7) >> 3;
 | ||||
| +	max_eccdata_size = (max_eccdata_size * ecc->caps->parity_bits + 7) >> 3;
 | ||||
|  	max_eccdata_size = round_up(max_eccdata_size, 4); | ||||
|  	ecc->eccdata = devm_kzalloc(dev, max_eccdata_size, GFP_KERNEL); | ||||
|  	if (!ecc->eccdata) | ||||
| --- a/drivers/mtd/nand/mtk_ecc.h
 | ||||
| +++ b/drivers/mtd/nand/mtk_ecc.h
 | ||||
| @@ -14,8 +14,6 @@
 | ||||
|   | ||||
|  #include <linux/types.h> | ||||
|   | ||||
| -#define ECC_PARITY_BITS		(14)
 | ||||
| -
 | ||||
|  enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1}; | ||||
|  enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE}; | ||||
|   | ||||
| @@ -43,6 +41,7 @@ int mtk_ecc_wait_done(struct mtk_ecc *,
 | ||||
|  int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *); | ||||
|  void mtk_ecc_disable(struct mtk_ecc *); | ||||
|  void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p); | ||||
| +unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc);
 | ||||
|   | ||||
|  struct mtk_ecc *of_mtk_ecc_get(struct device_node *); | ||||
|  void mtk_ecc_release(struct mtk_ecc *); | ||||
| --- a/drivers/mtd/nand/mtk_nand.c
 | ||||
| +++ b/drivers/mtd/nand/mtk_nand.c
 | ||||
| @@ -97,7 +97,6 @@
 | ||||
|   | ||||
|  #define MTK_TIMEOUT		(500000) | ||||
|  #define MTK_RESET_TIMEOUT	(1000000) | ||||
| -#define MTK_MAX_SECTOR		(16)
 | ||||
|  #define MTK_NAND_MAX_NSELS	(2) | ||||
|  #define MTK_NFC_MIN_SPARE	(16) | ||||
|  #define ACCTIMING(tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt) \ | ||||
| @@ -109,6 +108,8 @@ struct mtk_nfc_caps {
 | ||||
|  	u8 num_spare_size; | ||||
|  	u8 pageformat_spare_shift; | ||||
|  	u8 nfi_clk_div; | ||||
| +	u8 max_sector;
 | ||||
| +	u32 max_sector_size;
 | ||||
|  }; | ||||
|   | ||||
|  struct mtk_nfc_bad_mark_ctl { | ||||
| @@ -450,7 +451,7 @@ static inline u8 mtk_nfc_read_byte(struc
 | ||||
|  		 * set to max sector to allow the HW to continue reading over | ||||
|  		 * unaligned accesses | ||||
|  		 */ | ||||
| -		reg = (MTK_MAX_SECTOR << CON_SEC_SHIFT) | CON_BRD;
 | ||||
| +		reg = (nfc->caps->max_sector << CON_SEC_SHIFT) | CON_BRD;
 | ||||
|  		nfi_writel(nfc, reg, NFI_CON); | ||||
|   | ||||
|  		/* trigger to fetch data */ | ||||
| @@ -481,7 +482,7 @@ static void mtk_nfc_write_byte(struct mt
 | ||||
|  		reg = nfi_readw(nfc, NFI_CNFG) | CNFG_BYTE_RW; | ||||
|  		nfi_writew(nfc, reg, NFI_CNFG); | ||||
|   | ||||
| -		reg = MTK_MAX_SECTOR << CON_SEC_SHIFT | CON_BWR;
 | ||||
| +		reg = nfc->caps->max_sector << CON_SEC_SHIFT | CON_BWR;
 | ||||
|  		nfi_writel(nfc, reg, NFI_CON); | ||||
|   | ||||
|  		nfi_writew(nfc, STAR_EN, NFI_STRDATA); | ||||
| @@ -1126,9 +1127,11 @@ static void mtk_nfc_set_fdm(struct mtk_n
 | ||||
|  { | ||||
|  	struct nand_chip *nand = mtd_to_nand(mtd); | ||||
|  	struct mtk_nfc_nand_chip *chip = to_mtk_nand(nand); | ||||
| +	struct mtk_nfc *nfc = nand_get_controller_data(nand);
 | ||||
|  	u32 ecc_bytes; | ||||
|   | ||||
| -	ecc_bytes = DIV_ROUND_UP(nand->ecc.strength * ECC_PARITY_BITS, 8);
 | ||||
| +	ecc_bytes = DIV_ROUND_UP(nand->ecc.strength *
 | ||||
| +				 mtk_ecc_get_parity_bits(nfc->ecc), 8);
 | ||||
|   | ||||
|  	fdm->reg_size = chip->spare_per_sector - ecc_bytes; | ||||
|  	if (fdm->reg_size > NFI_FDM_MAX_SIZE) | ||||
| @@ -1208,7 +1211,8 @@ static int mtk_nfc_ecc_init(struct devic
 | ||||
|  		 * this controller only supports 512 and 1024 sizes | ||||
|  		 */ | ||||
|  		if (nand->ecc.size < 1024) { | ||||
| -			if (mtd->writesize > 512) {
 | ||||
| +			if (mtd->writesize > 512 &&
 | ||||
| +			    nfc->caps->max_sector_size > 512) {
 | ||||
|  				nand->ecc.size = 1024; | ||||
|  				nand->ecc.strength <<= 1; | ||||
|  			} else { | ||||
| @@ -1223,7 +1227,8 @@ static int mtk_nfc_ecc_init(struct devic
 | ||||
|  			return ret; | ||||
|   | ||||
|  		/* calculate oob bytes except ecc parity data */ | ||||
| -		free = ((nand->ecc.strength * ECC_PARITY_BITS) + 7) >> 3;
 | ||||
| +		free = (nand->ecc.strength * mtk_ecc_get_parity_bits(nfc->ecc)
 | ||||
| +			+ 7) >> 3;
 | ||||
|  		free = spare - free; | ||||
|   | ||||
|  		/* | ||||
| @@ -1233,10 +1238,12 @@ static int mtk_nfc_ecc_init(struct devic
 | ||||
|  		 */ | ||||
|  		if (free > NFI_FDM_MAX_SIZE) { | ||||
|  			spare -= NFI_FDM_MAX_SIZE; | ||||
| -			nand->ecc.strength = (spare << 3) / ECC_PARITY_BITS;
 | ||||
| +			nand->ecc.strength = (spare << 3) /
 | ||||
| +					     mtk_ecc_get_parity_bits(nfc->ecc);
 | ||||
|  		} else if (free < 0) { | ||||
|  			spare -= NFI_FDM_MIN_SIZE; | ||||
| -			nand->ecc.strength = (spare << 3) / ECC_PARITY_BITS;
 | ||||
| +			nand->ecc.strength = (spare << 3) /
 | ||||
| +					     mtk_ecc_get_parity_bits(nfc->ecc);
 | ||||
|  		} | ||||
|  	} | ||||
|   | ||||
| @@ -1389,6 +1396,8 @@ static const struct mtk_nfc_caps mtk_nfc
 | ||||
|  	.num_spare_size = 16, | ||||
|  	.pageformat_spare_shift = 4, | ||||
|  	.nfi_clk_div = 1, | ||||
| +	.max_sector = 16,
 | ||||
| +	.max_sector_size = 1024,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct mtk_nfc_caps mtk_nfc_caps_mt2712 = { | ||||
| @@ -1396,6 +1405,8 @@ static const struct mtk_nfc_caps mtk_nfc
 | ||||
|  	.num_spare_size = 19, | ||||
|  	.pageformat_spare_shift = 16, | ||||
|  	.nfi_clk_div = 2, | ||||
| +	.max_sector = 16,
 | ||||
| +	.max_sector_size = 1024,
 | ||||
|  }; | ||||
|   | ||||
|  static const struct of_device_id mtk_nfc_id_table[] = { | ||||
|  | @ -0,0 +1,109 @@ | |||
| From f395a149fbbc190afbadbdcf9ce95f85f78da22f Mon Sep 17 00:00:00 2001 | ||||
| From: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Date: Thu, 30 Nov 2017 22:10:45 +0800 | ||||
| Subject: [PATCH 167/224] mtd: nand: mtk: Support MT7622 NAND flash controller. | ||||
| 
 | ||||
| Add tables to support MT7622 NAND flash controller. | ||||
| 
 | ||||
| Signed-off-by: RogerCC Lin <rogercc.lin@mediatek.com> | ||||
| Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> | ||||
| ---
 | ||||
|  drivers/mtd/nand/mtk_ecc.c  | 26 ++++++++++++++++++++++++++ | ||||
|  drivers/mtd/nand/mtk_nand.c | 16 ++++++++++++++++ | ||||
|  2 files changed, 42 insertions(+) | ||||
| 
 | ||||
| --- a/drivers/mtd/nand/mtk_ecc.c
 | ||||
| +++ b/drivers/mtd/nand/mtk_ecc.c
 | ||||
| @@ -83,6 +83,10 @@ static const u8 ecc_strength_mt2712[] =
 | ||||
|  	40, 44, 48, 52, 56, 60, 68, 72, 80 | ||||
|  }; | ||||
|   | ||||
| +static const u8 ecc_strength_mt7622[] = {
 | ||||
| +	4, 6, 8, 10, 12, 14, 16
 | ||||
| +};
 | ||||
| +
 | ||||
|  enum mtk_ecc_regs { | ||||
|  	ECC_ENCPAR00, | ||||
|  	ECC_ENCIRQ_EN, | ||||
| @@ -110,6 +114,15 @@ static int mt2712_ecc_regs[] = {
 | ||||
|  	[ECC_DECIRQ_STA] =      0x204, | ||||
|  }; | ||||
|   | ||||
| +static int mt7622_ecc_regs[] = {
 | ||||
| +	[ECC_ENCPAR00] =        0x10,
 | ||||
| +	[ECC_ENCIRQ_EN] =       0x30,
 | ||||
| +	[ECC_ENCIRQ_STA] =      0x34,
 | ||||
| +	[ECC_DECDONE] =         0x11c,
 | ||||
| +	[ECC_DECIRQ_EN] =       0x140,
 | ||||
| +	[ECC_DECIRQ_STA] =      0x144,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc, | ||||
|  				     enum mtk_ecc_operation op) | ||||
|  { | ||||
| @@ -458,6 +471,16 @@ static const struct mtk_ecc_caps mtk_ecc
 | ||||
|  	.pg_irq_sel = 1, | ||||
|  }; | ||||
|   | ||||
| +static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
 | ||||
| +	.err_mask = 0x3f,
 | ||||
| +	.ecc_strength = ecc_strength_mt7622,
 | ||||
| +	.ecc_regs = mt7622_ecc_regs,
 | ||||
| +	.num_ecc_strength = 7,
 | ||||
| +	.ecc_mode_shift = 4,
 | ||||
| +	.parity_bits = 13,
 | ||||
| +	.pg_irq_sel = 0,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static const struct of_device_id mtk_ecc_dt_match[] = { | ||||
|  	{ | ||||
|  		.compatible = "mediatek,mt2701-ecc", | ||||
| @@ -465,6 +488,9 @@ static const struct of_device_id mtk_ecc
 | ||||
|  	}, { | ||||
|  		.compatible = "mediatek,mt2712-ecc", | ||||
|  		.data = &mtk_ecc_caps_mt2712, | ||||
| +	}, {
 | ||||
| +		.compatible = "mediatek,mt7622-ecc",
 | ||||
| +		.data = &mtk_ecc_caps_mt7622,
 | ||||
|  	}, | ||||
|  	{}, | ||||
|  }; | ||||
| --- a/drivers/mtd/nand/mtk_nand.c
 | ||||
| +++ b/drivers/mtd/nand/mtk_nand.c
 | ||||
| @@ -174,6 +174,10 @@ static const u8 spare_size_mt2712[] = {
 | ||||
|  	74 | ||||
|  }; | ||||
|   | ||||
| +static const u8 spare_size_mt7622[] = {
 | ||||
| +	16, 26, 27, 28
 | ||||
| +};
 | ||||
| +
 | ||||
|  static inline struct mtk_nfc_nand_chip *to_mtk_nand(struct nand_chip *nand) | ||||
|  { | ||||
|  	return container_of(nand, struct mtk_nfc_nand_chip, nand); | ||||
| @@ -1409,6 +1413,15 @@ static const struct mtk_nfc_caps mtk_nfc
 | ||||
|  	.max_sector_size = 1024, | ||||
|  }; | ||||
|   | ||||
| +static const struct mtk_nfc_caps mtk_nfc_caps_mt7622 = {
 | ||||
| +	.spare_size = spare_size_mt7622,
 | ||||
| +	.num_spare_size = 4,
 | ||||
| +	.pageformat_spare_shift = 4,
 | ||||
| +	.nfi_clk_div = 1,
 | ||||
| +	.max_sector = 8,
 | ||||
| +	.max_sector_size = 512,
 | ||||
| +};
 | ||||
| +
 | ||||
|  static const struct of_device_id mtk_nfc_id_table[] = { | ||||
|  	{ | ||||
|  		.compatible = "mediatek,mt2701-nfc", | ||||
| @@ -1416,6 +1429,9 @@ static const struct of_device_id mtk_nfc
 | ||||
|  	}, { | ||||
|  		.compatible = "mediatek,mt2712-nfc", | ||||
|  		.data = &mtk_nfc_caps_mt2712, | ||||
| +	}, {
 | ||||
| +		.compatible = "mediatek,mt7622-nfc",
 | ||||
| +		.data = &mtk_nfc_caps_mt7622,
 | ||||
|  	}, | ||||
|  	{} | ||||
|  }; | ||||
|  | @ -0,0 +1,26 @@ | |||
| From bb37b1aa5d1aadfcecd9189a653856099fbed507 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Thu, 7 Dec 2017 14:43:22 +0800 | ||||
| Subject: [PATCH 168/224] mmc: dt-bindings: add mmc support to MT7623 SoC | ||||
| 
 | ||||
| Add the devicetree binding for MT7623 SoC using MT2701 as the fallback. | ||||
| 
 | ||||
| Cc: devicetree@vger.kernel.org | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | ||||
| ---
 | ||||
|  Documentation/devicetree/bindings/mmc/mtk-sd.txt | 2 ++ | ||||
|  1 file changed, 2 insertions(+) | ||||
| 
 | ||||
| --- a/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | ||||
| +++ b/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | ||||
| @@ -12,6 +12,8 @@ Required properties:
 | ||||
|  	"mediatek,mt8173-mmc": for mmc host ip compatible with mt8173 | ||||
|  	"mediatek,mt2701-mmc": for mmc host ip compatible with mt2701 | ||||
|  	"mediatek,mt2712-mmc": for mmc host ip compatible with mt2712 | ||||
| +	"mediatek,mt7623-mmc", "mediatek,mt2701-mmc": for MT7623 SoC
 | ||||
| +
 | ||||
|  - reg: physical base address of the controller and length | ||||
|  - interrupts: Should contain MSDC interrupt number | ||||
|  - clocks: Should contain phandle for the clock feeding the MMC controller | ||||
|  | @ -0,0 +1,371 @@ | |||
| From 4e4c2d695a5daf6dc55b8713af720ef15b52c0e7 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Tue, 12 Dec 2017 14:24:18 +0800 | ||||
| Subject: [PATCH 169/224] dt-bindings: pinctrl: add bindings for MediaTek | ||||
|  MT7622 SoC | ||||
| 
 | ||||
| Add devicetree bindings for MediaTek MT7622 pinctrl driver. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Reviewed-by: Biao Huang <biao.huang@mediatek.com> | ||||
| Acked-by: Rob Herring <robh@kernel.org> | ||||
| Signed-off-by: Linus Walleij <linus.walleij@linaro.org> | ||||
| ---
 | ||||
|  .../devicetree/bindings/pinctrl/pinctrl-mt7622.txt | 351 +++++++++++++++++++++ | ||||
|  1 file changed, 351 insertions(+) | ||||
|  create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt7622.txt | ||||
| 
 | ||||
| --- /dev/null
 | ||||
| +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt7622.txt
 | ||||
| @@ -0,0 +1,351 @@
 | ||||
| +== MediaTek MT7622 pinctrl controller ==
 | ||||
| +
 | ||||
| +Required properties for the root node:
 | ||||
| + - compatible: Should be one of the following
 | ||||
| +	       "mediatek,mt7622-pinctrl" for MT7622 SoC
 | ||||
| + - reg: offset and length of the pinctrl space
 | ||||
| +
 | ||||
| + - gpio-controller: Marks the device node as a GPIO controller.
 | ||||
| + - #gpio-cells: Should be two. The first cell is the pin number and the
 | ||||
| +   second is the GPIO flags.
 | ||||
| +
 | ||||
| +Please refer to pinctrl-bindings.txt in this directory for details of the
 | ||||
| +common pinctrl bindings used by client devices, including the meaning of the
 | ||||
| +phrase "pin configuration node".
 | ||||
| +
 | ||||
| +MT7622 pin configuration nodes act as a container for an arbitrary number of
 | ||||
| +subnodes. Each of these subnodes represents some desired configuration for a
 | ||||
| +pin, a group, or a list of pins or groups. This configuration can include the
 | ||||
| +mux function to select on those pin(s)/group(s), and various pin configuration
 | ||||
| +parameters, such as pull-up, slew rate, etc.
 | ||||
| +
 | ||||
| +We support 2 types of configuration nodes. Those nodes can be either pinmux
 | ||||
| +nodes or pinconf nodes. Each configuration node can consist of multiple nodes
 | ||||
| +describing the pinmux and pinconf options.
 | ||||
| +
 | ||||
| +The name of each subnode doesn't matter as long as it is unique; all subnodes
 | ||||
| +should be enumerated and processed purely based on their content.
 | ||||
| +
 | ||||
| +== pinmux nodes content ==
 | ||||
| +
 | ||||
| +The following generic properties as defined in pinctrl-bindings.txt are valid
 | ||||
| +to specify in a pinmux subnode:
 | ||||
| +
 | ||||
| +Required properties are:
 | ||||
| + - groups: An array of strings. Each string contains the name of a group.
 | ||||
| +  Valid values for these names are listed below.
 | ||||
| + - function: A string containing the name of the function to mux to the
 | ||||
| +  group. Valid values for function names are listed below.
 | ||||
| +
 | ||||
| +== pinconf nodes content ==
 | ||||
| +
 | ||||
| +The following generic properties as defined in pinctrl-bindings.txt are valid
 | ||||
| +to specify in a pinconf subnode:
 | ||||
| +
 | ||||
| +Required properties are:
 | ||||
| + - pins: An array of strings. Each string contains the name of a pin.
 | ||||
| +  Valid values for these names are listed below.
 | ||||
| + - groups: An array of strings. Each string contains the name of a group.
 | ||||
| +  Valid values for these names are listed below.
 | ||||
| +
 | ||||
| +Optional properies are:
 | ||||
| + bias-disable, bias-pull, bias-pull-down, input-enable,
 | ||||
| + input-schmitt-enable, input-schmitt-disable, output-enable
 | ||||
| + output-low, output-high, drive-strength, slew-rate
 | ||||
| +
 | ||||
| + Valid arguments for 'slew-rate' are '0' for no slew rate controlled and '1' for
 | ||||
| + slower slew rate respectively.
 | ||||
| + Valid arguments for 'drive-strength', 4, 8, 12, or 16 in mA.
 | ||||
| +
 | ||||
| +The following specific properties as defined are valid to specify in a pinconf
 | ||||
| +subnode:
 | ||||
| +
 | ||||
| +Optional properties are:
 | ||||
| + - mediatek,tdsel: An integer describing the steps for output level shifter duty
 | ||||
| +   cycle when asserted (high pulse width adjustment). Valid arguments are from 0
 | ||||
| +   to 15.
 | ||||
| + - mediatek,rdsel: An integer describing the steps for input level shifter duty
 | ||||
| +   cycle when asserted (high pulse width adjustment). Valid arguments are from 0
 | ||||
| +   to 63.
 | ||||
| +
 | ||||
| +== Valid values for pins, function and groups on MT7622 ==
 | ||||
| +
 | ||||
| +Valid values for pins are:
 | ||||
| +pins can be referenced via the pin names as the below table shown and the
 | ||||
| +related physical number is also put ahead of those names which helps cross
 | ||||
| +references to pins between groups to know whether pins assignment conflict
 | ||||
| +happens among devices try to acquire those available pins.
 | ||||
| +
 | ||||
| +	Pin #:  Valid values for pins
 | ||||
| +	-----------------------------
 | ||||
| +	PIN 0: "GPIO_A"
 | ||||
| +	PIN 1: "I2S1_IN"
 | ||||
| +	PIN 2: "I2S1_OUT"
 | ||||
| +	PIN 3: "I2S_BCLK"
 | ||||
| +	PIN 4: "I2S_WS"
 | ||||
| +	PIN 5: "I2S_MCLK"
 | ||||
| +	PIN 6: "TXD0"
 | ||||
| +	PIN 7: "RXD0"
 | ||||
| +	PIN 8: "SPI_WP"
 | ||||
| +	PIN 9: "SPI_HOLD"
 | ||||
| +	PIN 10: "SPI_CLK"
 | ||||
| +	PIN 11: "SPI_MOSI"
 | ||||
| +	PIN 12: "SPI_MISO"
 | ||||
| +	PIN 13: "SPI_CS"
 | ||||
| +	PIN 14: "I2C_SDA"
 | ||||
| +	PIN 15: "I2C_SCL"
 | ||||
| +	PIN 16: "I2S2_IN"
 | ||||
| +	PIN 17: "I2S3_IN"
 | ||||
| +	PIN 18: "I2S4_IN"
 | ||||
| +	PIN 19: "I2S2_OUT"
 | ||||
| +	PIN 20: "I2S3_OUT"
 | ||||
| +	PIN 21: "I2S4_OUT"
 | ||||
| +	PIN 22: "GPIO_B"
 | ||||
| +	PIN 23: "MDC"
 | ||||
| +	PIN 24: "MDIO"
 | ||||
| +	PIN 25: "G2_TXD0"
 | ||||
| +	PIN 26: "G2_TXD1"
 | ||||
| +	PIN 27: "G2_TXD2"
 | ||||
| +	PIN 28: "G2_TXD3"
 | ||||
| +	PIN 29: "G2_TXEN"
 | ||||
| +	PIN 30: "G2_TXC"
 | ||||
| +	PIN 31: "G2_RXD0"
 | ||||
| +	PIN 32: "G2_RXD1"
 | ||||
| +	PIN 33: "G2_RXD2"
 | ||||
| +	PIN 34: "G2_RXD3"
 | ||||
| +	PIN 35: "G2_RXDV"
 | ||||
| +	PIN 36: "G2_RXC"
 | ||||
| +	PIN 37: "NCEB"
 | ||||
| +	PIN 38: "NWEB"
 | ||||
| +	PIN 39: "NREB"
 | ||||
| +	PIN 40: "NDL4"
 | ||||
| +	PIN 41: "NDL5"
 | ||||
| +	PIN 42: "NDL6"
 | ||||
| +	PIN 43: "NDL7"
 | ||||
| +	PIN 44: "NRB"
 | ||||
| +	PIN 45: "NCLE"
 | ||||
| +	PIN 46: "NALE"
 | ||||
| +	PIN 47: "NDL0"
 | ||||
| +	PIN 48: "NDL1"
 | ||||
| +	PIN 49: "NDL2"
 | ||||
| +	PIN 50: "NDL3"
 | ||||
| +	PIN 51: "MDI_TP_P0"
 | ||||
| +	PIN 52: "MDI_TN_P0"
 | ||||
| +	PIN 53: "MDI_RP_P0"
 | ||||
| +	PIN 54: "MDI_RN_P0"
 | ||||
| +	PIN 55: "MDI_TP_P1"
 | ||||
| +	PIN 56: "MDI_TN_P1"
 | ||||
| +	PIN 57: "MDI_RP_P1"
 | ||||
| +	PIN 58: "MDI_RN_P1"
 | ||||
| +	PIN 59: "MDI_RP_P2"
 | ||||
| +	PIN 60: "MDI_RN_P2"
 | ||||
| +	PIN 61: "MDI_TP_P2"
 | ||||
| +	PIN 62: "MDI_TN_P2"
 | ||||
| +	PIN 63: "MDI_TP_P3"
 | ||||
| +	PIN 64: "MDI_TN_P3"
 | ||||
| +	PIN 65: "MDI_RP_P3"
 | ||||
| +	PIN 66: "MDI_RN_P3"
 | ||||
| +	PIN 67: "MDI_RP_P4"
 | ||||
| +	PIN 68: "MDI_RN_P4"
 | ||||
| +	PIN 69: "MDI_TP_P4"
 | ||||
| +	PIN 70: "MDI_TN_P4"
 | ||||
| +	PIN 71: "PMIC_SCL"
 | ||||
| +	PIN 72: "PMIC_SDA"
 | ||||
| +	PIN 73: "SPIC1_CLK"
 | ||||
| +	PIN 74: "SPIC1_MOSI"
 | ||||
| +	PIN 75: "SPIC1_MISO"
 | ||||
| +	PIN 76: "SPIC1_CS"
 | ||||
| +	PIN 77: "GPIO_D"
 | ||||
| +	PIN 78: "WATCHDOG"
 | ||||
| +	PIN 79: "RTS3_N"
 | ||||
| +	PIN 80: "CTS3_N"
 | ||||
| +	PIN 81: "TXD3"
 | ||||
| +	PIN 82: "RXD3"
 | ||||
| +	PIN 83: "PERST0_N"
 | ||||
| +	PIN 84: "PERST1_N"
 | ||||
| +	PIN 85: "WLED_N"
 | ||||
| +	PIN 86: "EPHY_LED0_N"
 | ||||
| +	PIN 87: "AUXIN0"
 | ||||
| +	PIN 88: "AUXIN1"
 | ||||
| +	PIN 89: "AUXIN2"
 | ||||
| +	PIN 90: "AUXIN3"
 | ||||
| +	PIN 91: "TXD4"
 | ||||
| +	PIN 92: "RXD4"
 | ||||
| +	PIN 93: "RTS4_N"
 | ||||
| +	PIN 94: "CST4_N"
 | ||||
| +	PIN 95: "PWM1"
 | ||||
| +	PIN 96: "PWM2"
 | ||||
| +	PIN 97: "PWM3"
 | ||||
| +	PIN 98: "PWM4"
 | ||||
| +	PIN 99: "PWM5"
 | ||||
| +	PIN 100: "PWM6"
 | ||||
| +	PIN 101: "PWM7"
 | ||||
| +	PIN 102: "GPIO_E"
 | ||||
| +
 | ||||
| +Valid values for function are:
 | ||||
| +	"emmc", "eth", "i2c", "i2s", "ir", "led", "flash", "pcie",
 | ||||
| +	"pmic", "pwm", "sd", "spi", "tdm", "uart", "watchdog"
 | ||||
| +
 | ||||
| +Valid values for groups are:
 | ||||
| +additional data is put followingly with valid value allowing us to know which
 | ||||
| +applicable function and which relevant pins (in pin#) are able applied for that
 | ||||
| +group.
 | ||||
| +
 | ||||
| +	Valid value			function	pins (in pin#)
 | ||||
| +	-------------------------------------------------------------------------
 | ||||
| +	"emmc"				"emmc"		40, 41, 42, 43, 44, 45,
 | ||||
| +							47, 48, 49, 50
 | ||||
| +	"emmc_rst"			"emmc"		37
 | ||||
| +	"esw"				"eth"		51, 52, 53, 54, 55, 56,
 | ||||
| +							57, 58, 59, 60, 61, 62,
 | ||||
| +							63, 64, 65, 66, 67, 68,
 | ||||
| +							69, 70
 | ||||
| +	"esw_p0_p1"			"eth"		51, 52, 53, 54, 55, 56,
 | ||||
| +							57, 58
 | ||||
| +	"esw_p2_p3_p4"			"eth"		59, 60, 61, 62, 63, 64,
 | ||||
| +							65, 66, 67, 68, 69, 70
 | ||||
| +	"rgmii_via_esw"			"eth"		59, 60, 61, 62, 63, 64,
 | ||||
| +							65, 66, 67, 68, 69, 70
 | ||||
| +	"rgmii_via_gmac1"		"eth"		59, 60, 61, 62, 63, 64,
 | ||||
| +							65, 66, 67, 68, 69, 70
 | ||||
| +	"rgmii_via_gmac2"		"eth"		25, 26, 27, 28, 29, 30,
 | ||||
| +							31, 32, 33, 34, 35, 36
 | ||||
| +	"mdc_mdio"			"eth"		23, 24
 | ||||
| +	"i2c0"				"i2c"		14, 15
 | ||||
| +	"i2c1_0"			"i2c"		55, 56
 | ||||
| +	"i2c1_1"			"i2c"		73, 74
 | ||||
| +	"i2c1_2"			"i2c"		87, 88
 | ||||
| +	"i2c2_0"			"i2c"		57, 58
 | ||||
| +	"i2c2_1"			"i2c"		75, 76
 | ||||
| +	"i2c2_2"			"i2c"		89, 90
 | ||||
| +	"i2s_in_mclk_bclk_ws"		"i2s"		3, 4, 5
 | ||||
| +	"i2s1_in_data"			"i2s"		1
 | ||||
| +	"i2s2_in_data"			"i2s"		16
 | ||||
| +	"i2s3_in_data"			"i2s"		17
 | ||||
| +	"i2s4_in_data"			"i2s"		18
 | ||||
| +	"i2s_out_mclk_bclk_ws"		"i2s"		3, 4, 5
 | ||||
| +	"i2s1_out_data"			"i2s"		2
 | ||||
| +	"i2s2_out_data"			"i2s"		19
 | ||||
| +	"i2s3_out_data"			"i2s"		20
 | ||||
| +	"i2s4_out_data"			"i2s"		21
 | ||||
| +	"ir_0_tx"			"ir"		16
 | ||||
| +	"ir_1_tx"			"ir"		59
 | ||||
| +	"ir_2_tx"			"ir"		99
 | ||||
| +	"ir_0_rx"			"ir"		17
 | ||||
| +	"ir_1_rx"			"ir"		60
 | ||||
| +	"ir_2_rx"			"ir"		100
 | ||||
| +	"ephy_leds"			"led"		86, 91, 92, 93, 94
 | ||||
| +	"ephy0_led"			"led"		86
 | ||||
| +	"ephy1_led"			"led"		91
 | ||||
| +	"ephy2_led"			"led"		92
 | ||||
| +	"ephy3_led"			"led"		93
 | ||||
| +	"ephy4_led"			"led"		94
 | ||||
| +	"wled"				"led"		85
 | ||||
| +	"par_nand"			"flash"		37, 38, 39, 40, 41, 42,
 | ||||
| +							43, 44, 45, 46, 47, 48,
 | ||||
| +							49, 50
 | ||||
| +	"snfi"				"flash"		8, 9, 10, 11, 12, 13
 | ||||
| +	"spi_nor"			"flash"		8, 9, 10, 11, 12, 13
 | ||||
| +	"pcie0_0_waken"			"pcie"		14
 | ||||
| +	"pcie0_1_waken"			"pcie"		79
 | ||||
| +	"pcie1_0_waken"			"pcie"		14
 | ||||
| +	"pcie0_0_clkreq"		"pcie"		15
 | ||||
| +	"pcie0_1_clkreq"		"pcie"		80
 | ||||
| +	"pcie1_0_clkreq"		"pcie"		15
 | ||||
| +	"pcie0_pad_perst"		"pcie"		83
 | ||||
| +	"pcie1_pad_perst"		"pcie"		84
 | ||||
| +	"pmic_bus"			"pmic"		71, 72
 | ||||
| +	"pwm_ch1_0"			"pwm"		51
 | ||||
| +	"pwm_ch1_1"			"pwm"		73
 | ||||
| +	"pwm_ch1_2"			"pwm"		95
 | ||||
| +	"pwm_ch2_0"			"pwm"		52
 | ||||
| +	"pwm_ch2_1"			"pwm"		74
 | ||||
| +	"pwm_ch2_2"			"pwm"		96
 | ||||
| +	"pwm_ch3_0"			"pwm"		53
 | ||||
| +	"pwm_ch3_1"			"pwm"		75
 | ||||
| +	"pwm_ch3_2"			"pwm"		97
 | ||||
| +	"pwm_ch4_0"			"pwm"		54
 | ||||
| +	"pwm_ch4_1"			"pwm"		67
 | ||||
| +	"pwm_ch4_2"			"pwm"		76
 | ||||
| +	"pwm_ch4_3"			"pwm"		98
 | ||||
| +	"pwm_ch5_0"			"pwm"		68
 | ||||
| +	"pwm_ch5_1"			"pwm"		77
 | ||||
| +	"pwm_ch5_2"			"pwm"		99
 | ||||
| +	"pwm_ch6_0"			"pwm"		69
 | ||||
| +	"pwm_ch6_1"			"pwm"		78
 | ||||
| +	"pwm_ch6_2"			"pwm"		81
 | ||||
| +	"pwm_ch6_3"			"pwm"		100
 | ||||
| +	"pwm_ch7_0"			"pwm"		70
 | ||||
| +	"pwm_ch7_1"			"pwm"		82
 | ||||
| +	"pwm_ch7_2"			"pwm"		101
 | ||||
| +	"sd_0"				"sd"		16, 17, 18, 19, 20, 21
 | ||||
| +	"sd_1"				"sd"		25, 26, 27, 28, 29, 30
 | ||||
| +	"spic0_0"			"spi"		63, 64, 65, 66
 | ||||
| +	"spic0_1"			"spi"		79, 80, 81, 82
 | ||||
| +	"spic1_0"			"spi"		67, 68, 69, 70
 | ||||
| +	"spic1_1"			"spi"		73, 74, 75, 76
 | ||||
| +	"spic2_0_wp_hold"		"spi"		8, 9
 | ||||
| +	"spic2_0"			"spi"		10, 11, 12, 13
 | ||||
| +	"tdm_0_out_mclk_bclk_ws"	"tdm"		8, 9, 10
 | ||||
| +	"tdm_0_in_mclk_bclk_ws"		"tdm"		11, 12, 13
 | ||||
| +	"tdm_0_out_data"		"tdm"		20
 | ||||
| +	"tdm_0_in_data"			"tdm"		21
 | ||||
| +	"tdm_1_out_mclk_bclk_ws"	"tdm"		57, 58, 59
 | ||||
| +	"tdm_1_in_mclk_bclk_ws"		"tdm"		60, 61, 62
 | ||||
| +	"tdm_1_out_data"		"tdm"		55
 | ||||
| +	"tdm_1_in_data"			"tdm"		56
 | ||||
| +	"uart0_0_tx_rx"			"uart"		6, 7
 | ||||
| +	"uart1_0_tx_rx"			"uart"		55, 56
 | ||||
| +	"uart1_0_rts_cts"		"uart"		57, 58
 | ||||
| +	"uart1_1_tx_rx"			"uart"		73, 74
 | ||||
| +	"uart1_1_rts_cts"		"uart"		75, 76
 | ||||
| +	"uart2_0_tx_rx"			"uart"		3, 4
 | ||||
| +	"uart2_0_rts_cts"		"uart"		1, 2
 | ||||
| +	"uart2_1_tx_rx"			"uart"		51, 52
 | ||||
| +	"uart2_1_rts_cts"		"uart"		53, 54
 | ||||
| +	"uart2_2_tx_rx"			"uart"		59, 60
 | ||||
| +	"uart2_2_rts_cts"		"uart"		61, 62
 | ||||
| +	"uart2_3_tx_rx"			"uart"		95, 96
 | ||||
| +	"uart3_0_tx_rx"			"uart"		57, 58
 | ||||
| +	"uart3_1_tx_rx"			"uart"		81, 82
 | ||||
| +	"uart3_1_rts_cts"		"uart"		79, 80
 | ||||
| +	"uart4_0_tx_rx"			"uart"		61, 62
 | ||||
| +	"uart4_1_tx_rx"			"uart"		91, 92
 | ||||
| +	"uart4_1_rts_cts"		"uart"		93, 94
 | ||||
| +	"uart4_2_tx_rx"			"uart"		97, 98
 | ||||
| +	"uart4_2_rts_cts"		"uart"		95, 96
 | ||||
| +	"watchdog"			"watchdog"	78
 | ||||
| +
 | ||||
| +Example:
 | ||||
| +
 | ||||
| +	pio: pinctrl@10211000 {
 | ||||
| +		compatible = "mediatek,mt7622-pinctrl";
 | ||||
| +		reg = <0 0x10211000 0 0x1000>;
 | ||||
| +		gpio-controller;
 | ||||
| +		#gpio-cells = <2>;
 | ||||
| +
 | ||||
| +		pinctrl_eth_default: eth-default {
 | ||||
| +			mux-mdio {
 | ||||
| +				groups = "mdc_mdio";
 | ||||
| +				function = "eth";
 | ||||
| +				drive-strength = <12>;
 | ||||
| +			};
 | ||||
| +
 | ||||
| +			mux-gmac2 {
 | ||||
| +				groups = "gmac2";
 | ||||
| +				function = "eth";
 | ||||
| +				drive-strength = <12>;
 | ||||
| +			};
 | ||||
| +
 | ||||
| +			mux-esw {
 | ||||
| +				groups = "esw";
 | ||||
| +				function = "eth";
 | ||||
| +				drive-strength = <8>;
 | ||||
| +			};
 | ||||
| +
 | ||||
| +			conf-mdio {
 | ||||
| +				pins = "MDC";
 | ||||
| +				bias-pull-up;
 | ||||
| +			};
 | ||||
| +		};
 | ||||
| +	};
 | ||||
|  | @ -0,0 +1,32 @@ | |||
| From 547700768b2e7a105ed27a3b955fd9b7142987d7 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Tue, 12 Dec 2017 14:24:19 +0800 | ||||
| Subject: [PATCH 170/224] pinctrl: mediatek: cleanup for placing all drivers | ||||
|  under the menu | ||||
| 
 | ||||
| Since lots of MediaTek drivers had been added, it seems slightly better | ||||
| for that adding cleanup for placing MediaTek pinctrl drivers under the | ||||
| independent menu as other kinds of drivers usually was done. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Reviewed-by: Biao Huang <biao.huang@mediatek.com> | ||||
| Signed-off-by: Linus Walleij <linus.walleij@linaro.org> | ||||
| ---
 | ||||
|  drivers/pinctrl/mediatek/Kconfig | 5 +++-- | ||||
|  1 file changed, 3 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/pinctrl/mediatek/Kconfig
 | ||||
| +++ b/drivers/pinctrl/mediatek/Kconfig
 | ||||
| @@ -1,4 +1,5 @@
 | ||||
| -if ARCH_MEDIATEK || COMPILE_TEST
 | ||||
| +menu "MediaTek pinctrl drivers"
 | ||||
| +	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
|   | ||||
|  config PINCTRL_MTK | ||||
|  	bool | ||||
| @@ -46,4 +47,4 @@ config PINCTRL_MT6397
 | ||||
|  	default MFD_MT6397 | ||||
|  	select PINCTRL_MTK | ||||
|   | ||||
| -endif
 | ||||
| +endmenu
 | ||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -0,0 +1,223 @@ | |||
| From 13ee94af58240b75550f413fece707987d563193 Mon Sep 17 00:00:00 2001 | ||||
| From: Sean Wang <sean.wang@mediatek.com> | ||||
| Date: Wed, 20 Dec 2017 14:42:58 +0800 | ||||
| Subject: [PATCH 172/224] clk: mediatek: group drivers under indpendent menu | ||||
| 
 | ||||
| Getting much MediaTek clock driver have been added to CCF, so it's | ||||
| better adding the cleanup for grouping drivers under the independent | ||||
| menu to simplify configuration selection. In addition, really trivial | ||||
| fixups for typos are added in the same patch. | ||||
| 
 | ||||
| Signed-off-by: Sean Wang <sean.wang@mediatek.com> | ||||
| Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> | ||||
| ---
 | ||||
|  drivers/clk/mediatek/Kconfig | 96 +++++++++++++++++++++++--------------------- | ||||
|  1 file changed, 50 insertions(+), 46 deletions(-) | ||||
| 
 | ||||
| --- a/drivers/clk/mediatek/Kconfig
 | ||||
| +++ b/drivers/clk/mediatek/Kconfig
 | ||||
| @@ -1,136 +1,139 @@
 | ||||
|  # | ||||
| -# MediaTek SoC drivers
 | ||||
| +# MediaTek Clock Drivers
 | ||||
|  # | ||||
| +menu "Clock driver for MediaTek SoC"
 | ||||
| +	depends on ARCH_MEDIATEK || COMPILE_TEST
 | ||||
| +
 | ||||
|  config COMMON_CLK_MEDIATEK | ||||
|  	bool | ||||
|  	---help--- | ||||
| -	  Mediatek SoCs' clock support.
 | ||||
| +	  MediaTek SoCs' clock support.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701 | ||||
| -	bool "Clock driver for Mediatek MT2701"
 | ||||
| +	bool "Clock driver for MediaTek MT2701"
 | ||||
|  	depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST | ||||
|  	select COMMON_CLK_MEDIATEK | ||||
|  	default ARCH_MEDIATEK && ARM | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 basic clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 basic clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_MMSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 mmsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 mmsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 mmsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 mmsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_IMGSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 imgsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 imgsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 imgsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 imgsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_VDECSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 vdecsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 vdecsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 vdecsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 vdecsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_HIFSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 hifsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 hifsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 hifsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 hifsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_ETHSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 ethsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 ethsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 ethsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 ethsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2701_BDPSYS | ||||
| -	bool "Clock driver for Mediatek MT2701 bdpsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2701 bdpsys"
 | ||||
|  	depends on COMMON_CLK_MT2701 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2701 bdpsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2701 bdpsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712 | ||||
| -	bool "Clock driver for Mediatek MT2712"
 | ||||
| +	bool "Clock driver for MediaTek MT2712"
 | ||||
|  	depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST | ||||
|  	select COMMON_CLK_MEDIATEK | ||||
|  	default ARCH_MEDIATEK && ARM64 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 basic clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 basic clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_BDPSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 bdpsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 bdpsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 bdpsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 bdpsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_IMGSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 imgsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 imgsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 imgsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 imgsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_JPGDECSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 jpgdecsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 jpgdecsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 jpgdecsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 jpgdecsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_MFGCFG | ||||
| -	bool "Clock driver for Mediatek MT2712 mfgcfg"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 mfgcfg"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 mfgcfg clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 mfgcfg clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_MMSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 mmsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 mmsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 mmsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 mmsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_VDECSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 vdecsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 vdecsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 vdecsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 vdecsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT2712_VENCSYS | ||||
| -	bool "Clock driver for Mediatek MT2712 vencsys"
 | ||||
| +	bool "Clock driver for MediaTek MT2712 vencsys"
 | ||||
|  	depends on COMMON_CLK_MT2712 | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT2712 vencsys clocks.
 | ||||
| +	  This driver supports MediaTek MT2712 vencsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT6797 | ||||
| -       bool "Clock driver for Mediatek MT6797"
 | ||||
| +       bool "Clock driver for MediaTek MT6797"
 | ||||
|         depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST | ||||
|         select COMMON_CLK_MEDIATEK | ||||
|         default ARCH_MEDIATEK && ARM64 | ||||
|         ---help--- | ||||
| -         This driver supports Mediatek MT6797 basic clocks.
 | ||||
| +         This driver supports MediaTek MT6797 basic clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT6797_MMSYS | ||||
| -       bool "Clock driver for Mediatek MT6797 mmsys"
 | ||||
| +       bool "Clock driver for MediaTek MT6797 mmsys"
 | ||||
|         depends on COMMON_CLK_MT6797 | ||||
|         ---help--- | ||||
| -         This driver supports Mediatek MT6797 mmsys clocks.
 | ||||
| +         This driver supports MediaTek MT6797 mmsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT6797_IMGSYS | ||||
| -       bool "Clock driver for Mediatek MT6797 imgsys"
 | ||||
| +       bool "Clock driver for MediaTek MT6797 imgsys"
 | ||||
|         depends on COMMON_CLK_MT6797 | ||||
|         ---help--- | ||||
| -         This driver supports Mediatek MT6797 imgsys clocks.
 | ||||
| +         This driver supports MediaTek MT6797 imgsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT6797_VDECSYS | ||||
| -       bool "Clock driver for Mediatek MT6797 vdecsys"
 | ||||
| +       bool "Clock driver for MediaTek MT6797 vdecsys"
 | ||||
|         depends on COMMON_CLK_MT6797 | ||||
|         ---help--- | ||||
| -         This driver supports Mediatek MT6797 vdecsys clocks.
 | ||||
| +         This driver supports MediaTek MT6797 vdecsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT6797_VENCSYS | ||||
| -       bool "Clock driver for Mediatek MT6797 vencsys"
 | ||||
| +       bool "Clock driver for MediaTek MT6797 vencsys"
 | ||||
|         depends on COMMON_CLK_MT6797 | ||||
|         ---help--- | ||||
| -         This driver supports Mediatek MT6797 vencsys clocks.
 | ||||
| +         This driver supports MediaTek MT6797 vencsys clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT7622 | ||||
|  	bool "Clock driver for MediaTek MT7622" | ||||
| @@ -163,17 +166,18 @@ config COMMON_CLK_MT7622_AUDSYS
 | ||||
|  	  to audio consumers such as I2S and TDM. | ||||
|   | ||||
|  config COMMON_CLK_MT8135 | ||||
| -	bool "Clock driver for Mediatek MT8135"
 | ||||
| +	bool "Clock driver for MediaTek MT8135"
 | ||||
|  	depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST | ||||
|  	select COMMON_CLK_MEDIATEK | ||||
|  	default ARCH_MEDIATEK && ARM | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT8135 clocks.
 | ||||
| +	  This driver supports MediaTek MT8135 clocks.
 | ||||
|   | ||||
|  config COMMON_CLK_MT8173 | ||||
| -	bool "Clock driver for Mediatek MT8173"
 | ||||
| +	bool "Clock driver for MediaTek MT8173"
 | ||||
|  	depends on ARCH_MEDIATEK || COMPILE_TEST | ||||
|  	select COMMON_CLK_MEDIATEK | ||||
|  	default ARCH_MEDIATEK | ||||
|  	---help--- | ||||
| -	  This driver supports Mediatek MT8173 clocks.
 | ||||
| +	  This driver supports MediaTek MT8173 clocks.
 | ||||
| +endmenu
 | ||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue