mediatek: backport upstream mediatek patches
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
		
							parent
							
								
									4f67c1522d
								
							
						
					
					
						commit
						050da2107a
					
				@ -1,13 +0,0 @@
 | 
				
			|||||||
#
 | 
					 | 
				
			||||||
# Copyright (C) 2009 OpenWrt.org
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SUBTARGET:=32
 | 
					 | 
				
			||||||
BOARDNAME:=32bit
 | 
					 | 
				
			||||||
CPU_TYPE:=cortex-a7
 | 
					 | 
				
			||||||
CPU_SUBTYPE:=neon-vfpv4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
define Target/Description
 | 
					 | 
				
			||||||
	Build firmware images for MediaTek 32bit ARM based boards.
 | 
					 | 
				
			||||||
endef
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -5,14 +5,12 @@ include $(TOPDIR)/rules.mk
 | 
				
			|||||||
ARCH:=arm
 | 
					ARCH:=arm
 | 
				
			||||||
BOARD:=mediatek
 | 
					BOARD:=mediatek
 | 
				
			||||||
BOARDNAME:=MediaTek Ralink ARM
 | 
					BOARDNAME:=MediaTek Ralink ARM
 | 
				
			||||||
SUBTARGETS:=32
 | 
					SUBTARGETS:=mt7623
 | 
				
			||||||
FEATURES:=squashfs nand ramdisk fpu
 | 
					FEATURES:=squashfs nand ramdisk fpu
 | 
				
			||||||
MAINTAINER:=John Crispin <john@phrozen.org>
 | 
					MAINTAINER:=John Crispin <john@phrozen.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KERNEL_PATCHVER:=4.14
 | 
					KERNEL_PATCHVER:=4.14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KERNELNAME:=Image dtbs zImage
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
include $(INCLUDE_DIR)/target.mk
 | 
					include $(INCLUDE_DIR)/target.mk
 | 
				
			||||||
DEFAULT_PACKAGES += \
 | 
					DEFAULT_PACKAGES += \
 | 
				
			||||||
	kmod-mt76 kmod-leds-gpio kmod-gpio-button-hotplug \
 | 
						kmod-mt76 kmod-leds-gpio kmod-gpio-button-hotplug \
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,3 @@
 | 
				
			|||||||
::sysinit:/etc/init.d/rcS S boot
 | 
					::sysinit:/etc/init.d/rcS S boot
 | 
				
			||||||
::shutdown:/etc/init.d/rcS K shutdown
 | 
					::shutdown:/etc/init.d/rcS K shutdown
 | 
				
			||||||
ttyS0::askfirst:/usr/libexec/login.sh
 | 
					::askconsole:/usr/libexec/login.sh
 | 
				
			||||||
 | 
				
			|||||||
@ -1,49 +1,29 @@
 | 
				
			|||||||
#
 | 
					platform_do_upgrade() {                 
 | 
				
			||||||
# Copyright (C) 2016 OpenWrt.org
 | 
						default_do_upgrade "$ARGV"                                               
 | 
				
			||||||
#
 | 
					}                                                                                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_do_upgrade() {
 | 
					PART_NAME=firmware
 | 
				
			||||||
	local tar_file="$1"
 | 
					 | 
				
			||||||
	local board="$(board_name)"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(board_name)" in
 | 
					platform_check_image() {                                                         
 | 
				
			||||||
	mediatek,mt7623-rfb-nand-ephy |\
 | 
						local board=$(board_name)                                                
 | 
				
			||||||
	mediatek,mt7623-rfb-nand)
 | 
						local magic="$(get_magic_long "$1")"                                     
 | 
				
			||||||
		nand_do_upgrade $1
 | 
					 | 
				
			||||||
		;;
 | 
					 | 
				
			||||||
	*)
 | 
					 | 
				
			||||||
		echo "flashing kernel"
 | 
					 | 
				
			||||||
		tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		echo "flashing rootfs"
 | 
						[ "$#" -gt 1 ] && return 1                                               
 | 
				
			||||||
		tar xf $tar_file sysupgrade-$board/root -O | mtd write - rootfs
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return 0
 | 
						case "$board" in                                                       
 | 
				
			||||||
		;;
 | 
						bananapi,bpi-r2)                                                       
 | 
				
			||||||
	esac
 | 
							[ "$magic" != "27051956" ] && {   
 | 
				
			||||||
}
 | 
								echo "Invalid image type."
 | 
				
			||||||
 | 
								return 1                                     
 | 
				
			||||||
 | 
							}                                                    
 | 
				
			||||||
 | 
							return 0                                             
 | 
				
			||||||
 | 
							;;                                                   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
						*)                                                           
 | 
				
			||||||
	local tar_file="$1"
 | 
					 | 
				
			||||||
	local board=$(board_name)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	case "$board" in
 | 
					 | 
				
			||||||
	bananapi,bpi-r2 |\
 | 
					 | 
				
			||||||
	mediatek,mt7623a-rfb-emmc)
 | 
					 | 
				
			||||||
		local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
 | 
					 | 
				
			||||||
		local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
 | 
					 | 
				
			||||||
		;;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	*)
 | 
					 | 
				
			||||||
		echo "Sysupgrade is not supported on your board yet."
 | 
							echo "Sysupgrade is not supported on your board yet."
 | 
				
			||||||
		return 1
 | 
							return 1                                             
 | 
				
			||||||
		;;
 | 
							;;                                
 | 
				
			||||||
	esac
 | 
						esac                                      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
 | 
						return 0                                                                                         
 | 
				
			||||||
		echo "The upgarde image is corrupt."
 | 
					}                   
 | 
				
			||||||
		return 1
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,32 +0,0 @@
 | 
				
			|||||||
define Image/BuilduImage
 | 
					 | 
				
			||||||
	$(CP) $(KDIR)/zImage$(2) $(KDIR)/zImage-$(1)$(2)
 | 
					 | 
				
			||||||
	cat $(LINUX_DIR)/arch/arm/boot/dts/$1.dtb >> $(KDIR)/zImage-$(1)$(2)
 | 
					 | 
				
			||||||
	mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)'  -d $(KDIR)/zImage-$(1)$(2) $(KDIR)/uImage-$(1)$(2)
 | 
					 | 
				
			||||||
endef
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
define Image/Build/SysupgradeCombined
 | 
					 | 
				
			||||||
	$(call Image/BuilduImage,$1)
 | 
					 | 
				
			||||||
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
 | 
					 | 
				
			||||||
	$(call Image/BuilduImage,$1,-initramfs)
 | 
					 | 
				
			||||||
	$(CP) $(KDIR)/uImage-$(1)-initramfs $(BIN_DIR)/$(IMG_PREFIX)-uImage-$(1)-initramfs
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
	mkdir -p "$(KDIR_TMP)/sysupgrade-$(3)/"
 | 
					 | 
				
			||||||
	echo "BOARD=$(3)" > "$(KDIR_TMP)/sysupgrade-$(3)/CONTROL"
 | 
					 | 
				
			||||||
	$(CP) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(3)/root"
 | 
					 | 
				
			||||||
	$(CP) "$(KDIR)/uImage-$(1)" "$(KDIR_TMP)/sysupgrade-$(3)/kernel"
 | 
					 | 
				
			||||||
	(cd "$(KDIR_TMP)"; $(TAR) cvf \
 | 
					 | 
				
			||||||
		"$(BIN_DIR)/$(IMG_PREFIX)-$(3)-sysupgrade.tar" sysupgrade-$(3) \
 | 
					 | 
				
			||||||
			$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
endef
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
COMPAT_BPI-R2:=bananapi,bpi-r2
 | 
					 | 
				
			||||||
COMPAT_EMMC:=mediatek,mt7623a-rfb-emmc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
define Image/Build/squashfs
 | 
					 | 
				
			||||||
	$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
 | 
					 | 
				
			||||||
	$(CP) $(KDIR)/root.squashfs $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	$(call Image/Build/SysupgradeCombined,mt7623n-bananapi-bpi-r2,squashfs,$$(COMPAT_BPI-R2))
 | 
					 | 
				
			||||||
	$(call Image/Build/SysupgradeCombined,mt7623a-rfb-emmc,squashfs,$$(COMPAT_EMMC))
 | 
					 | 
				
			||||||
endef
 | 
					 | 
				
			||||||
@ -1,10 +1,42 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Copyright (C) 2012-2015 OpenWrt.org
 | 
				
			||||||
 | 
					# Copyright (C) 2016-2017 LEDE project
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# This is free software, licensed under the GNU General Public License v2.
 | 
				
			||||||
 | 
					# See /LICENSE for more information.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
include $(TOPDIR)/rules.mk
 | 
					include $(TOPDIR)/rules.mk
 | 
				
			||||||
include $(INCLUDE_DIR)/image.mk
 | 
					include $(INCLUDE_DIR)/image.mk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include $(SUBTARGET).mk
 | 
					# for arm
 | 
				
			||||||
 | 
					KERNEL_LOADADDR := 0x80008000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# build dtb
 | 
				
			||||||
 | 
					define Build/dtb
 | 
				
			||||||
 | 
					        $(call Image/BuildDTB,$(DEVICE_DTS_DIR)/$(DEVICE_DTS).dts,$(DEVICE_DTS_DIR)/$(DEVICE_DTS).dtb)
 | 
				
			||||||
 | 
						$(CP) $(DEVICE_DTS_DIR)/$(DEVICE_DTS).dtb $(BIN_DIR)/
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# default all platform image(fit) build 
 | 
				
			||||||
 | 
					define Device/Default
 | 
				
			||||||
 | 
					  PROFILES = Default $$(DEVICE_NAME)
 | 
				
			||||||
 | 
					  KERNEL_NAME := zImage
 | 
				
			||||||
 | 
					  FILESYSTEMS := squashfs
 | 
				
			||||||
 | 
					  DEVICE_DTS_DIR := $(DTS_DIR)
 | 
				
			||||||
 | 
					  IMAGES := sysupgrade.bin
 | 
				
			||||||
 | 
					  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata 
 | 
				
			||||||
 | 
					  KERNEL_NAME := zImage
 | 
				
			||||||
 | 
					  KERNEL := dtb | kernel-bin | append-dtb | uImage none
 | 
				
			||||||
 | 
					  KERNEL_INITRAMFS := dtb | kernel-bin | append-dtb | uImage none
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ifeq ($(SUBTARGET),mt7623)
 | 
				
			||||||
 | 
					include mt7623.mk
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
define Image/Build
 | 
					define Image/Build
 | 
				
			||||||
	$(call Image/Build/$(1),$(1))
 | 
						$(call Image/Build/$(1),$(1))
 | 
				
			||||||
endef
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(eval $(call BuildImage))
 | 
					$(eval $(call BuildImage))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								target/linux/mediatek/image/mt7623.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								target/linux/mediatek/image/mt7623.mk
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					define Device/7623n-bananapi-bpi-r2
 | 
				
			||||||
 | 
					  DEVICE_TITLE := MTK7623n BananaPi R2
 | 
				
			||||||
 | 
					  DEVICE_DTS := mt7623n-bananapi-bpi-r2
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TARGET_DEVICES += 7623n-bananapi-bpi-r2
 | 
				
			||||||
@ -1,4 +1,3 @@
 | 
				
			|||||||
# CONFIG_AHCI_MTK is not set
 | 
					 | 
				
			||||||
# CONFIG_AIO is not set
 | 
					# CONFIG_AIO is not set
 | 
				
			||||||
CONFIG_ALIGNMENT_TRAP=y
 | 
					CONFIG_ALIGNMENT_TRAP=y
 | 
				
			||||||
CONFIG_ARCH_CLOCKSOURCE_DATA=y
 | 
					CONFIG_ARCH_CLOCKSOURCE_DATA=y
 | 
				
			||||||
@ -63,7 +62,7 @@ CONFIG_CLKDEV_LOOKUP=y
 | 
				
			|||||||
CONFIG_CLKSRC_MMIO=y
 | 
					CONFIG_CLKSRC_MMIO=y
 | 
				
			||||||
CONFIG_CLONE_BACKWARDS=y
 | 
					CONFIG_CLONE_BACKWARDS=y
 | 
				
			||||||
CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,jffs2"
 | 
					CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,jffs2"
 | 
				
			||||||
CONFIG_CMDLINE_FORCE=y
 | 
					CONFIG_CMDLINE_FROM_BOOTLOADER=y
 | 
				
			||||||
CONFIG_COMMON_CLK=y
 | 
					CONFIG_COMMON_CLK=y
 | 
				
			||||||
CONFIG_COMMON_CLK_MEDIATEK=y
 | 
					CONFIG_COMMON_CLK_MEDIATEK=y
 | 
				
			||||||
CONFIG_COMMON_CLK_MT2701=y
 | 
					CONFIG_COMMON_CLK_MT2701=y
 | 
				
			||||||
@ -73,6 +72,7 @@ CONFIG_COMMON_CLK_MT2701_HIFSYS=y
 | 
				
			|||||||
CONFIG_COMMON_CLK_MT2701_IMGSYS=y
 | 
					CONFIG_COMMON_CLK_MT2701_IMGSYS=y
 | 
				
			||||||
CONFIG_COMMON_CLK_MT2701_MMSYS=y
 | 
					CONFIG_COMMON_CLK_MT2701_MMSYS=y
 | 
				
			||||||
CONFIG_COMMON_CLK_MT2701_VDECSYS=y
 | 
					CONFIG_COMMON_CLK_MT2701_VDECSYS=y
 | 
				
			||||||
 | 
					# CONFIG_COMMON_CLK_MT7622 is not set
 | 
				
			||||||
# CONFIG_COMMON_CLK_MT8135 is not set
 | 
					# CONFIG_COMMON_CLK_MT8135 is not set
 | 
				
			||||||
# CONFIG_COMMON_CLK_MT8173 is not set
 | 
					# CONFIG_COMMON_CLK_MT8173 is not set
 | 
				
			||||||
CONFIG_COMPACTION=y
 | 
					CONFIG_COMPACTION=y
 | 
				
			||||||
@ -257,7 +257,6 @@ CONFIG_IIO=y
 | 
				
			|||||||
# CONFIG_IIO_BUFFER is not set
 | 
					# CONFIG_IIO_BUFFER is not set
 | 
				
			||||||
# CONFIG_IIO_TRIGGER is not set
 | 
					# CONFIG_IIO_TRIGGER is not set
 | 
				
			||||||
CONFIG_INITRAMFS_COMPRESSION=""
 | 
					CONFIG_INITRAMFS_COMPRESSION=""
 | 
				
			||||||
# CONFIG_INITRAMFS_FORCE is not set
 | 
					 | 
				
			||||||
CONFIG_INITRAMFS_ROOT_GID=1000
 | 
					CONFIG_INITRAMFS_ROOT_GID=1000
 | 
				
			||||||
CONFIG_INITRAMFS_ROOT_UID=1000
 | 
					CONFIG_INITRAMFS_ROOT_UID=1000
 | 
				
			||||||
CONFIG_INITRAMFS_SOURCE="/openwrt/trunk/build_dir/target-arm_cortex-a7_musl-1.1.14_eabi/root-mediatek /openwrt/trunk/target/linux/generic/image/initramfs-base-files.txt"
 | 
					CONFIG_INITRAMFS_SOURCE="/openwrt/trunk/build_dir/target-arm_cortex-a7_musl-1.1.14_eabi/root-mediatek /openwrt/trunk/target/linux/generic/image/initramfs-base-files.txt"
 | 
				
			||||||
@ -276,11 +275,11 @@ CONFIG_LIBFDT=y
 | 
				
			|||||||
CONFIG_LOCK_SPIN_ON_OWNER=y
 | 
					CONFIG_LOCK_SPIN_ON_OWNER=y
 | 
				
			||||||
CONFIG_LZO_COMPRESS=y
 | 
					CONFIG_LZO_COMPRESS=y
 | 
				
			||||||
CONFIG_LZO_DECOMPRESS=y
 | 
					CONFIG_LZO_DECOMPRESS=y
 | 
				
			||||||
CONFIG_MACH_MT2701=y
 | 
					# CONFIG_MACH_MT2701 is not set
 | 
				
			||||||
# CONFIG_MACH_MT6589 is not set
 | 
					# CONFIG_MACH_MT6589 is not set
 | 
				
			||||||
# CONFIG_MACH_MT6592 is not set
 | 
					# CONFIG_MACH_MT6592 is not set
 | 
				
			||||||
CONFIG_MACH_MT7623=y
 | 
					CONFIG_MACH_MT7623=y
 | 
				
			||||||
CONFIG_MACH_MT8127=y
 | 
					# CONFIG_MACH_MT8127 is not set
 | 
				
			||||||
# CONFIG_MACH_MT8135 is not set
 | 
					# CONFIG_MACH_MT8135 is not set
 | 
				
			||||||
CONFIG_MAGIC_SYSRQ=y
 | 
					CONFIG_MAGIC_SYSRQ=y
 | 
				
			||||||
CONFIG_MDIO_BITBANG=y
 | 
					CONFIG_MDIO_BITBANG=y
 | 
				
			||||||
@ -311,6 +310,8 @@ CONFIG_MTD_NAND=y
 | 
				
			|||||||
CONFIG_MTD_NAND_ECC=y
 | 
					CONFIG_MTD_NAND_ECC=y
 | 
				
			||||||
CONFIG_MTD_NAND_MTK=y
 | 
					CONFIG_MTD_NAND_MTK=y
 | 
				
			||||||
CONFIG_MTD_SPI_NOR=y
 | 
					CONFIG_MTD_SPI_NOR=y
 | 
				
			||||||
 | 
					CONFIG_MTD_SPLIT_FIRMWARE=y
 | 
				
			||||||
 | 
					CONFIG_MTD_SPLIT_UIMAGE_FW=y
 | 
				
			||||||
CONFIG_MTD_UBI=y
 | 
					CONFIG_MTD_UBI=y
 | 
				
			||||||
CONFIG_MTD_UBI_BEB_LIMIT=20
 | 
					CONFIG_MTD_UBI_BEB_LIMIT=20
 | 
				
			||||||
CONFIG_MTD_UBI_BLOCK=y
 | 
					CONFIG_MTD_UBI_BLOCK=y
 | 
				
			||||||
@ -318,6 +319,7 @@ CONFIG_MTD_UBI_BLOCK=y
 | 
				
			|||||||
# CONFIG_MTD_UBI_GLUEBI is not set
 | 
					# CONFIG_MTD_UBI_GLUEBI is not set
 | 
				
			||||||
CONFIG_MTD_UBI_WL_THRESHOLD=4096
 | 
					CONFIG_MTD_UBI_WL_THRESHOLD=4096
 | 
				
			||||||
CONFIG_MTK_EFUSE=y
 | 
					CONFIG_MTK_EFUSE=y
 | 
				
			||||||
 | 
					# CONFIG_MTK_HSDMA is not set
 | 
				
			||||||
CONFIG_MTK_INFRACFG=y
 | 
					CONFIG_MTK_INFRACFG=y
 | 
				
			||||||
# CONFIG_MTK_IOMMU is not set
 | 
					# CONFIG_MTK_IOMMU is not set
 | 
				
			||||||
# CONFIG_MTK_IOMMU_V1 is not set
 | 
					# CONFIG_MTK_IOMMU_V1 is not set
 | 
				
			||||||
@ -377,7 +379,6 @@ CONFIG_PHY_MTK_TPHY=y
 | 
				
			|||||||
CONFIG_PINCTRL=y
 | 
					CONFIG_PINCTRL=y
 | 
				
			||||||
CONFIG_PINCTRL_MT2701=y
 | 
					CONFIG_PINCTRL_MT2701=y
 | 
				
			||||||
CONFIG_PINCTRL_MT6397=y
 | 
					CONFIG_PINCTRL_MT6397=y
 | 
				
			||||||
CONFIG_PINCTRL_MT8127=y
 | 
					 | 
				
			||||||
CONFIG_PINCTRL_MTK=y
 | 
					CONFIG_PINCTRL_MTK=y
 | 
				
			||||||
CONFIG_PM=y
 | 
					CONFIG_PM=y
 | 
				
			||||||
CONFIG_PM_CLK=y
 | 
					CONFIG_PM_CLK=y
 | 
				
			||||||
@ -422,6 +423,7 @@ CONFIG_RPS=y
 | 
				
			|||||||
CONFIG_RTC_CLASS=y
 | 
					CONFIG_RTC_CLASS=y
 | 
				
			||||||
# CONFIG_RTC_DRV_CMOS is not set
 | 
					# CONFIG_RTC_DRV_CMOS is not set
 | 
				
			||||||
# CONFIG_RTC_DRV_MT6397 is not set
 | 
					# CONFIG_RTC_DRV_MT6397 is not set
 | 
				
			||||||
 | 
					# CONFIG_RTC_DRV_MT7622 is not set
 | 
				
			||||||
CONFIG_RTC_I2C_AND_SPI=y
 | 
					CONFIG_RTC_I2C_AND_SPI=y
 | 
				
			||||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
 | 
					CONFIG_RWSEM_SPIN_ON_OWNER=y
 | 
				
			||||||
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 | 
					CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 | 
				
			||||||
@ -470,7 +472,6 @@ CONFIG_UNINLINE_SPIN_UNLOCK=y
 | 
				
			|||||||
CONFIG_USB=y
 | 
					CONFIG_USB=y
 | 
				
			||||||
CONFIG_USB_COMMON=y
 | 
					CONFIG_USB_COMMON=y
 | 
				
			||||||
# CONFIG_USB_EHCI_HCD is not set
 | 
					# CONFIG_USB_EHCI_HCD is not set
 | 
				
			||||||
# CONFIG_USB_MTU3 is not set
 | 
					 | 
				
			||||||
CONFIG_USB_SUPPORT=y
 | 
					CONFIG_USB_SUPPORT=y
 | 
				
			||||||
CONFIG_USB_XHCI_HCD=y
 | 
					CONFIG_USB_XHCI_HCD=y
 | 
				
			||||||
CONFIG_USB_XHCI_MTK=y
 | 
					CONFIG_USB_XHCI_MTK=y
 | 
				
			||||||
							
								
								
									
										16
									
								
								target/linux/mediatek/mt7623/target.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								target/linux/mediatek/mt7623/target.mk
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Copyright (C) 2009 OpenWrt.org
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ARCH:=arm
 | 
				
			||||||
 | 
					SUBTARGET:=mt7623
 | 
				
			||||||
 | 
					BOARDNAME:=MT7623
 | 
				
			||||||
 | 
					CPU_TYPE:=cortex-a7
 | 
				
			||||||
 | 
					CPU_SUBTYPE:=neon-vfpv4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					KERNELNAME:=Image dtbs zImage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Target/Description
 | 
				
			||||||
 | 
						Build firmware images for MediaTek mt7623 ARM based boards.
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,120 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/include/dt-bindings/reset/mt7622-reset.h b/include/dt-bindings/reset/mt7622-reset.h
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..234052f80417
 | 
				
			||||||
 | 
					--- /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 */
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,76 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index c2048382830f..f095faac1e04 100644
 | 
				
			||||||
 | 
					--- 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_wrapper *wrp)
 | 
				
			||||||
 | 
					 	/* 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_device *pdev)
 | 
				
			||||||
 | 
					 		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_device *pdev)
 | 
				
			||||||
 | 
					 	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;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,117 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index b26fffc58446..112723d6e7bc 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					index e42d308b8dc2..4dd9508a60b5 100644
 | 
				
			||||||
 | 
					--- 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 *ssusb)
 | 
				
			||||||
 | 
					 	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 *ssusb)
 | 
				
			||||||
 | 
					 	/* 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 *ssusb)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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 *ssusb, bool suspend)
 | 
				
			||||||
 | 
					 	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;
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index 088e3e685c4f..9edad30c8ae5 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					@@ -276,6 +276,10 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	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;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,126 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index 112723d6e7bc..6d3278e46431 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					index 4dd9508a60b5..edcc59148171 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					@@ -79,20 +79,6 @@ int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
 | 
				
			||||||
 | 
					 	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(struct ssusb_mtk *ssusb,
 | 
				
			||||||
 | 
					 	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 *ssusb)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,233 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index 6d3278e46431..2795294ec92a 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index 9edad30c8ae5..fb8992011bde 100644
 | 
				
			||||||
 | 
					--- 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 ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 		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_mtk *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_mtk *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 ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 		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 = get_optional_clk(dev, "ref_ck");
 | 
				
			||||||
 | 
					+	if (IS_ERR(ssusb->ref_clk))
 | 
				
			||||||
 | 
					+		return PTR_ERR(ssusb->ref_clk);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		ssusb->ref_clk = NULL;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	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(struct device *dev)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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(struct device *dev)
 | 
				
			||||||
 | 
					 		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;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,373 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index 2795294ec92a..ef2dc92a2109 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
 | 
				
			||||||
 | 
					index 947579842ad7..cd4528f5f337 100644
 | 
				
			||||||
 | 
					--- 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 *mtu)
 | 
				
			||||||
 | 
					 	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 *ssusb)
 | 
				
			||||||
 | 
					 		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 *ssusb)
 | 
				
			||||||
 | 
					 gadget_err:
 | 
				
			||||||
 | 
					 	device_init_wakeup(dev, false);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+dma_mask_err:
 | 
				
			||||||
 | 
					 irq_err:
 | 
				
			||||||
 | 
					 	mtu3_hw_exit(mtu);
 | 
				
			||||||
 | 
					 	ssusb->u3d = NULL;
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
 | 
				
			||||||
 | 
					index 06b29664470f..b6059752dc12 100644
 | 
				
			||||||
 | 
					--- 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)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
 | 
				
			||||||
 | 
					index 7d9ba8a52368..42145a3f1422 100644
 | 
				
			||||||
 | 
					--- 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 mtu3_ep *mep, struct mtu3_request *mreq)
 | 
				
			||||||
 | 
					 	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 mtu3_ep *mep, struct mtu3_request *mreq)
 | 
				
			||||||
 | 
					 	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(struct mtu3 *mtu, u8 epnum)
 | 
				
			||||||
 | 
					 	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(struct mtu3 *mtu, u8 epnum)
 | 
				
			||||||
 | 
					 	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, u8 epnum)
 | 
				
			||||||
 | 
					 	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, u8 epnum)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,290 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index ef2dc92a2109..b0c2b5dca045 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
 | 
				
			||||||
 | 
					index 560256115b23..ec442cd5a1ad 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_dr.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_dr.c
 | 
				
			||||||
 | 
					@@ -261,21 +261,22 @@ static void extcon_register_dwork(struct work_struct *work)
 | 
				
			||||||
 | 
					  * 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 ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* It is enough to delay 1s for waiting for host initialization */
 | 
				
			||||||
 | 
					-	schedule_delayed_work(&otg_sx->extcon_reg_dwork, HZ);
 | 
				
			||||||
 | 
					+	} 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);
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -407,8 +436,8 @@ void ssusb_otg_switch_exit(struct ssusb_mtk *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);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_dr.h b/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					index 9b228b5811b0..0f0cbac00192 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					@@ -87,6 +87,8 @@ static inline void ssusb_gadget_exit(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 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 otg_switch_mtk *otg_sx, int is_on)
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+static inline void
 | 
				
			||||||
 | 
					+ssusb_set_force_mode(struct ssusb_mtk *ssusb, enum mtu3_dr_force_mode mode)
 | 
				
			||||||
 | 
					+{}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #endif		/* _MTU3_DR_H_ */
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					index edcc59148171..ec76b86dd887 100644
 | 
				
			||||||
 | 
					--- 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 *ssusb, bool suspend)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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 ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	 */
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
 | 
				
			||||||
 | 
					index b6059752dc12..a7e35f6ad90a 100644
 | 
				
			||||||
 | 
					--- 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)
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index fb8992011bde..1e473b068650 100644
 | 
				
			||||||
 | 
					--- 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 ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 			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;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,165 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index b0c2b5dca045..d80e4e813248 100644
 | 
				
			||||||
 | 
					--- 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,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /**
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
 | 
				
			||||||
 | 
					index cd4528f5f337..67f7a309aba7 100644
 | 
				
			||||||
 | 
					--- 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 *mep, bool set)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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 *mtu)
 | 
				
			||||||
 | 
					 		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 mtu3 *mtu)
 | 
				
			||||||
 | 
					 		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 *ssusb)
 | 
				
			||||||
 | 
					 	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;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
 | 
				
			||||||
 | 
					index 434fca58143c..b495471f689f 100644
 | 
				
			||||||
 | 
					--- 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 *mep)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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_gadget *gadget)
 | 
				
			||||||
 | 
					 		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);
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c
 | 
				
			||||||
 | 
					index 958d74dd2b78..020b25314a68 100644
 | 
				
			||||||
 | 
					--- 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 struct usb_ctrlrequest *setup)
 | 
				
			||||||
 | 
					 	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 mtu3 *mtu,
 | 
				
			||||||
 | 
					 		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 mtu3 *mtu,
 | 
				
			||||||
 | 
					 		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 mtu3 *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
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
 | 
				
			||||||
 | 
					index a7e35f6ad90a..6953436a1688 100644
 | 
				
			||||||
 | 
					--- 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)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index 1e473b068650..7ca81f4e78a3 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					@@ -300,10 +300,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 	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");
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index 7ca81f4e78a3..9ff33579b42e 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					@@ -283,10 +283,8 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 		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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
 | 
				
			||||||
 | 
					index 67f7a309aba7..7c149a7da14e 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_core.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_core.c
 | 
				
			||||||
 | 
					@@ -115,7 +115,9 @@ static int mtu3_device_enable(struct mtu3 *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 mtu3 *mtu)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					index 49f54767cd21..7c611d14a0a0 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					index 7c611d14a0a0..49c982bb5bfc 100644
 | 
				
			||||||
 | 
					--- 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>;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					index 49c982bb5bfc..b2271d8e6b50 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
 | 
				
			||||||
 | 
					index 107700d00df4..bf80e3f96f8c 100644
 | 
				
			||||||
 | 
					--- 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 {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,139 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index f095faac1e04..06930e2ebe4c 100644
 | 
				
			||||||
 | 
					--- 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_wrapper *wrp, u32 adr, u32 wdata)
 | 
				
			||||||
 | 
					 	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_wrapper *wrp, u32 adr, u32 *rdata)
 | 
				
			||||||
 | 
					 	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(struct pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					 		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_wrapper *wrp)
 | 
				
			||||||
 | 
					 		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_regmap_config = {
 | 
				
			||||||
 | 
					 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[] = {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,137 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index 06930e2ebe4c..2d3a8faae124 100644
 | 
				
			||||||
 | 
					--- 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 pmic_wrapper *wrp,
 | 
				
			||||||
 | 
					 	} 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_wrapper *wrp, u32 adr, u32 *rdata)
 | 
				
			||||||
 | 
					 	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_mt6323 = {
 | 
				
			||||||
 | 
					 	.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[] = {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,232 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index 2d3a8faae124..e3398e37a7a6 100644
 | 
				
			||||||
 | 
					--- 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_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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_specific(struct pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					 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_wrapper *wrp)
 | 
				
			||||||
 | 
					 		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_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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_regmap_config = {
 | 
				
			||||||
 | 
					 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_mt6323 = {
 | 
				
			||||||
 | 
					 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_mt6380 = {
 | 
				
			||||||
 | 
					 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,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,103 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index e3398e37a7a6..45c3e44d8f40 100644
 | 
				
			||||||
 | 
					--- 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 irqno, void *dev_id)
 | 
				
			||||||
 | 
					 	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_regmap_config = {
 | 
				
			||||||
 | 
					 	.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_mt6323 = {
 | 
				
			||||||
 | 
					 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_mt6380 = {
 | 
				
			||||||
 | 
					 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_slave_match_tbl[] = {
 | 
				
			||||||
 | 
					 		.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_device *pdev)
 | 
				
			||||||
 | 
					 	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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,124 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index 45c3e44d8f40..cbc3f0e82337 100644
 | 
				
			||||||
 | 
					--- 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 pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					+/*
 | 
				
			||||||
 | 
					+ * 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)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	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);
 | 
				
			||||||
 | 
					+	/*
 | 
				
			||||||
 | 
					+	 * 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);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					+	/*
 | 
				
			||||||
 | 
					+	 * 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(struct pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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 pwrap_mt8135 = {
 | 
				
			||||||
 | 
					 	.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 pwrap_mt8173 = {
 | 
				
			||||||
 | 
					 	.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,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,242 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
 | 
				
			||||||
 | 
					index cbc3f0e82337..5d61d127e1d7 100644
 | 
				
			||||||
 | 
					--- 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_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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_specific(struct pmic_wrapper *wrp)
 | 
				
			||||||
 | 
					 	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 pwrap_mt2701 = {
 | 
				
			||||||
 | 
					 	.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_pwrap_match_tbl[] = {
 | 
				
			||||||
 | 
					 		.compatible = "mediatek,mt2701-pwrap",
 | 
				
			||||||
 | 
					 		.data = &pwrap_mt2701,
 | 
				
			||||||
 | 
					 	}, {
 | 
				
			||||||
 | 
					+		.compatible = "mediatek,mt7622-pwrap",
 | 
				
			||||||
 | 
					+		.data = &pwrap_mt7622,
 | 
				
			||||||
 | 
					+	}, {
 | 
				
			||||||
 | 
					 		.compatible = "mediatek,mt8135-pwrap",
 | 
				
			||||||
 | 
					 		.data = &pwrap_mt8135,
 | 
				
			||||||
 | 
					 	}, {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
 | 
				
			||||||
 | 
					index 609bb3424c14..a7d0667338f2 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
 | 
				
			||||||
 | 
					index 6b54ee8c1262..ab69f5fce261 100644
 | 
				
			||||||
 | 
					--- 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"
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,91 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					index 721a2a1c97ef..402385f2562a 100644
 | 
				
			||||||
 | 
					--- 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 mtk_tphy *tphy,
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+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,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index 8fb60657ed4f..c197a6d9e157 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					@@ -606,15 +606,10 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* 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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
 | 
				
			||||||
 | 
					index 6e7ddf6cafae..bfc51bc902b8 100644
 | 
				
			||||||
 | 
					--- 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_endpoint *ep,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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)
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index c197a6d9e157..9502ca408f01 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					@@ -492,7 +492,6 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
 | 
				
			||||||
 | 
					 /* 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 *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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index 9502ca408f01..7a92bb782e5c 100644
 | 
				
			||||||
 | 
					--- 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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 	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) {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index 7a92bb782e5c..97ba51e4e149 100644
 | 
				
			||||||
 | 
					--- 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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 	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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 	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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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)
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					index 3aa5e1d25064..db55a12f1585 100644
 | 
				
			||||||
 | 
					--- 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 */
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,93 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index 97ba51e4e149..d60463c07c54 100644
 | 
				
			||||||
 | 
					--- 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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 		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 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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(struct xhci_hcd_mtk *mtk,
 | 
				
			||||||
 | 
					 	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)) {
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					index db55a12f1585..67783a7af509 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,146 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index d60463c07c54..e5caabe7eebe 100644
 | 
				
			||||||
 | 
					--- 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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 	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 xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 		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 platform_device *pdev)
 | 
				
			||||||
 | 
					 		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 */
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					index 67783a7af509..45ff5c67efb5 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
 | 
				
			||||||
 | 
					index fa5692dec832..bc09a2e4faeb 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					index 5611a2e4ddf0..2d9b459bd890 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,63 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					index 2d9b459bd890..30595964876a 100644
 | 
				
			||||||
 | 
					--- 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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
 | 
				
			||||||
 | 
					index 840f9405dcf0..56d3668e2c50 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,133 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c
 | 
				
			||||||
 | 
					index c258c7adf1c5..abe455ccd68b 100644
 | 
				
			||||||
 | 
					--- 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 spi_nor *nor, u8 opcode, u8 *buf,
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 		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 platform_device *pdev)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	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_driver = {
 | 
				
			||||||
 | 
					 	.remove = mtk_nor_drv_remove,
 | 
				
			||||||
 | 
					 	.driver = {
 | 
				
			||||||
 | 
					 		.name = "mtk-nor",
 | 
				
			||||||
 | 
					+		.pm = MTK_NOR_DEV_PM_OPS,
 | 
				
			||||||
 | 
					 		.of_match_table = mtk_nor_of_ids,
 | 
				
			||||||
 | 
					 	},
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/rtc/rtc-mt7622.txt b/Documentation/devicetree/bindings/rtc/rtc-mt7622.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..09fe8f51476f
 | 
				
			||||||
 | 
					--- /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";
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,481 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
 | 
				
			||||||
 | 
					index e0e58f3b1420..322752ebc5a7 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
 | 
				
			||||||
 | 
					index 7230014c92af..5ec891a81f4f 100644
 | 
				
			||||||
 | 
					--- a/drivers/rtc/Makefile
 | 
				
			||||||
 | 
					+++ b/drivers/rtc/Makefile
 | 
				
			||||||
 | 
					@@ -102,6 +102,7 @@ obj-$(CONFIG_RTC_DRV_MPC5121)	+= rtc-mpc5121.o
 | 
				
			||||||
 | 
					 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
 | 
				
			||||||
 | 
					diff --git a/drivers/rtc/rtc-mt7622.c b/drivers/rtc/rtc-mt7622.c
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..d79b9ae4d237
 | 
				
			||||||
 | 
					--- /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");
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
 | 
				
			||||||
 | 
					index 322752ebc5a7..616fe53c788e 100644
 | 
				
			||||||
 | 
					--- 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"
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
 | 
				
			||||||
 | 
					index ade5fc4c3819..57f4cdedf137 100644
 | 
				
			||||||
 | 
					--- a/drivers/mtd/nand/Makefile
 | 
				
			||||||
 | 
					+++ b/drivers/mtd/nand/Makefile
 | 
				
			||||||
 | 
					@@ -58,7 +58,7 @@ obj-$(CONFIG_MTD_NAND_SUNXI)		+= sunxi_nand.o
 | 
				
			||||||
 | 
					 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/mmc/mtk-sd.txt b/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | 
				
			||||||
 | 
					index 4182ea36ca5b..72d2a734ab85 100644
 | 
				
			||||||
 | 
					--- 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 the core properties in mmc.txt
 | 
				
			||||||
 | 
					 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 {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,192 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index 267f7ab08420..643c795f1bdd 100644
 | 
				
			||||||
 | 
					--- 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_host *host, u32 ns, u32 clks)
 | 
				
			||||||
 | 
					 		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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 			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 platform_device *pdev)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 	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_pm_ops = {
 | 
				
			||||||
 | 
					 	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,
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,226 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | 
				
			||||||
 | 
					index cd977db7630c..19fc116346d6 100644
 | 
				
			||||||
 | 
					--- 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"
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,bdpsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,bdpsys.txt
 | 
				
			||||||
 | 
					index 4137196dd686..4010e37c53a0 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
 | 
				
			||||||
 | 
					index 047b11ae5f45..868bd51a98be 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | 
				
			||||||
 | 
					index 58d58e2006b8..a3430cd96d0f 100644
 | 
				
			||||||
 | 
					--- 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"
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,jpgdecsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,jpgdecsys.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..2df799cd06a7
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mcucfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mcucfg.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..b8fb03f3613e
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mfgcfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mfgcfg.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..859e67b416d5
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
 | 
				
			||||||
 | 
					index 70529e0b58e9..4eb8bbe15c01 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | 
				
			||||||
 | 
					index e494366782aa..d9f092eb3550 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | 
				
			||||||
 | 
					index ec93ecbb9f3c..2024fc909d69 100644
 | 
				
			||||||
 | 
					--- 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"
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,vdecsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,vdecsys.txt
 | 
				
			||||||
 | 
					index d150104f928a..ea40d05089f8 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,vencsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,vencsys.txt
 | 
				
			||||||
 | 
					index 8a93be643647..851545357e94 100644
 | 
				
			||||||
 | 
					--- 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 various clocks to the system.
 | 
				
			||||||
 | 
					 Required Properties:
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 - compatible: Should be one of:
 | 
				
			||||||
 | 
					+	- "mediatek,mt2712-vencsys", "syscon"
 | 
				
			||||||
 | 
					 	- "mediatek,mt6797-vencsys", "syscon"
 | 
				
			||||||
 | 
					 	- "mediatek,mt8173-vencsys", "syscon"
 | 
				
			||||||
 | 
					 - #clock-cells: Must be 1
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,452 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/include/dt-bindings/clock/mt2712-clk.h b/include/dt-bindings/clock/mt2712-clk.h
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..48a8e797a617
 | 
				
			||||||
 | 
					--- /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 */
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -0,0 +1,217 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
 | 
				
			||||||
 | 
					index 19fc116346d6..b404d592ce58 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..9b8f578d5e19
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt
 | 
				
			||||||
 | 
					index 768f3a5bc055..7aa3fa167668 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,hifsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,hifsys.txt
 | 
				
			||||||
 | 
					index beed7b594cea..f5629d64cef2 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
 | 
				
			||||||
 | 
					index a3430cd96d0f..566f153f9f83 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,pciesys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pciesys.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..d5d5f1227665
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,pericfg.txt
 | 
				
			||||||
 | 
					index d9f092eb3550..fb58ca8c2770 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..d113b8e741f3
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,ssusbsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ssusbsys.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..00760019da00
 | 
				
			||||||
 | 
					--- /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>;
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,topckgen.txt
 | 
				
			||||||
 | 
					index 2024fc909d69..24014a7e2332 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,316 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/include/dt-bindings/clock/mt7622-clk.h b/include/dt-bindings/clock/mt7622-clk.h
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..3e514ed51d15
 | 
				
			||||||
 | 
					--- /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 */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
 | 
				
			||||||
 | 
					index b99a27372965..26396ef53bde 100644
 | 
				
			||||||
 | 
					--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
 | 
				
			||||||
 | 
					+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
 | 
				
			||||||
 | 
					@@ -682,8 +682,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>,
 | 
				
			||||||
 | 
					@@ -693,8 +692,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>,
 | 
				
			||||||
 | 
					@@ -704,8 +702,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>,
 | 
				
			||||||
 | 
					@@ -715,8 +712,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>,
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index 643c795f1bdd..ab2fbbbdfda3 100644
 | 
				
			||||||
 | 
					--- 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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 		       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 mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,261 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index ab2fbbbdfda3..bcd83d6f2b86 100644
 | 
				
			||||||
 | 
					--- 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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 	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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 	 */
 | 
				
			||||||
 | 
					 	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, void *dev_id)
 | 
				
			||||||
 | 
					 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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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 @@ static int msdc_tune_response(struct mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 		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 @@ static int msdc_tune_response(struct mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 		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 @@ static int msdc_tune_response(struct mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 	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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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 @@ static int msdc_tune_data(struct mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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 mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	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 mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 #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_host *host)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,175 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index bcd83d6f2b86..8113bacc1540 100644
 | 
				
			||||||
 | 
					--- 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 mt8135_compat = {
 | 
				
			||||||
 | 
					 	.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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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 @@ static int msdc_tune_response(struct mmc_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 			      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(struct mmc_host *mmc, struct mmc_ios *ios)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index 8113bacc1540..eceaee86ba4d 100644
 | 
				
			||||||
 | 
					--- 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 mt8135_compat = {
 | 
				
			||||||
 | 
					 	.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 mt8173_compat = {
 | 
				
			||||||
 | 
					 	.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 mt2701_compat = {
 | 
				
			||||||
 | 
					 	.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 mt2712_compat = {
 | 
				
			||||||
 | 
					 	.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_host *host)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,173 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index eceaee86ba4d..94d16a3a8d94 100644
 | 
				
			||||||
 | 
					--- 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 mt8135_compat = {
 | 
				
			||||||
 | 
					 	.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 mt8173_compat = {
 | 
				
			||||||
 | 
					 	.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 mt2701_compat = {
 | 
				
			||||||
 | 
					 	.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 mt2712_compat = {
 | 
				
			||||||
 | 
					 	.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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,90 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index 94d16a3a8d94..a2f26c9b17b4 100644
 | 
				
			||||||
 | 
					--- 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_host *host, u32 ns, u32 clks)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 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 msdc_host *host)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 			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_host *host, unsigned char timing, u32 hz)
 | 
				
			||||||
 | 
					 		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 platform_device *pdev)
 | 
				
			||||||
 | 
					 		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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index a2f26c9b17b4..d75a93d6803f 100644
 | 
				
			||||||
 | 
					--- 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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	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_ops = {
 | 
				
			||||||
 | 
					 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);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index d75a93d6803f..95759bba0dd0 100644
 | 
				
			||||||
 | 
					--- 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(struct mmc_host *mmc, struct mmc_ios *ios)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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_host *host)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
 | 
				
			||||||
 | 
					index 95759bba0dd0..27a62254f12f 100644
 | 
				
			||||||
 | 
					--- 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_host *mmc, u32 opcode)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,150 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
 | 
				
			||||||
 | 
					index b52f3afb2ba1..f5d97e0ad52b 100644
 | 
				
			||||||
 | 
					--- 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 pwm_chip *chip, struct pwm_device *pwm)
 | 
				
			||||||
 | 
					 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_device *pdev)
 | 
				
			||||||
 | 
					 	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_device *pdev)
 | 
				
			||||||
 | 
					 	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 platform_device *pdev)
 | 
				
			||||||
 | 
					 	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);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
 | 
				
			||||||
 | 
					index d86a7d131cc0..6d0101e13ef6 100644
 | 
				
			||||||
 | 
					--- 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 *dev)
 | 
				
			||||||
 | 
					 	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 *dev)
 | 
				
			||||||
 | 
					 	/* 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;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
 | 
				
			||||||
 | 
					index 18c4bd9a5c65..62aec5cdbb26 100644
 | 
				
			||||||
 | 
					--- a/drivers/cpufreq/mediatek-cpufreq.c
 | 
				
			||||||
 | 
					+++ b/drivers/cpufreq/mediatek-cpufreq.c
 | 
				
			||||||
 | 
					@@ -574,6 +574,7 @@ static struct platform_driver mtk_cpufreq_platdrv = {
 | 
				
			||||||
 | 
					 /* 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", },
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/mtd/mtk-nand.txt b/Documentation/devicetree/bindings/mtd/mtk-nand.txt
 | 
				
			||||||
 | 
					index dbf9e054c11c..0025bc4c94a0 100644
 | 
				
			||||||
 | 
					--- 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.
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,389 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
 | 
				
			||||||
 | 
					index c51d214d169e..6610eefaa92b 100644
 | 
				
			||||||
 | 
					--- 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(struct mtk_ecc *ecc,
 | 
				
			||||||
 | 
					 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 *ecc, struct mtk_ecc_config *config)
 | 
				
			||||||
 | 
					 		/* 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 *ecc, struct mtk_ecc_config *config)
 | 
				
			||||||
 | 
					 	} 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, struct mtk_ecc_config *config)
 | 
				
			||||||
 | 
					 		 */
 | 
				
			||||||
 | 
					 		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, struct mtk_ecc_config *config,
 | 
				
			||||||
 | 
					 	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_ecc *ecc, u32 *p)
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 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_device *pdev)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	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)
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_ecc.h b/drivers/mtd/nand/mtk_ecc.h
 | 
				
			||||||
 | 
					index d245c14f1b80..a455df080952 100644
 | 
				
			||||||
 | 
					--- 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 *, enum mtk_ecc_operation);
 | 
				
			||||||
 | 
					 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 *);
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
 | 
				
			||||||
 | 
					index 6d0101e13ef6..7349aa846f9a 100644
 | 
				
			||||||
 | 
					--- 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(struct mtd_info *mtd)
 | 
				
			||||||
 | 
					 		 * 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 mtd_info *mtd, u8 byte)
 | 
				
			||||||
 | 
					 		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_nfc_fdm *fdm, struct mtd_info *mtd)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	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 device *dev, struct mtd_info *mtd)
 | 
				
			||||||
 | 
					 		 * 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 device *dev, struct mtd_info *mtd)
 | 
				
			||||||
 | 
					 			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 device *dev, struct mtd_info *mtd)
 | 
				
			||||||
 | 
					 		 */
 | 
				
			||||||
 | 
					 		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_caps_mt2701 = {
 | 
				
			||||||
 | 
					 	.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_caps_mt2712 = {
 | 
				
			||||||
 | 
					 	.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[] = {
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,116 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
 | 
				
			||||||
 | 
					index 6610eefaa92b..40d86a861a70 100644
 | 
				
			||||||
 | 
					--- 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_caps_mt2712 = {
 | 
				
			||||||
 | 
					 	.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_dt_match[] = {
 | 
				
			||||||
 | 
					 	}, {
 | 
				
			||||||
 | 
					 		.compatible = "mediatek,mt2712-ecc",
 | 
				
			||||||
 | 
					 		.data = &mtk_ecc_caps_mt2712,
 | 
				
			||||||
 | 
					+	}, {
 | 
				
			||||||
 | 
					+		.compatible = "mediatek,mt7622-ecc",
 | 
				
			||||||
 | 
					+		.data = &mtk_ecc_caps_mt7622,
 | 
				
			||||||
 | 
					 	},
 | 
				
			||||||
 | 
					 	{},
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
 | 
				
			||||||
 | 
					index 7349aa846f9a..8f71b405d639 100644
 | 
				
			||||||
 | 
					--- 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_caps_mt2712 = {
 | 
				
			||||||
 | 
					 	.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_id_table[] = {
 | 
				
			||||||
 | 
					 	}, {
 | 
				
			||||||
 | 
					 		.compatible = "mediatek,mt2712-nfc",
 | 
				
			||||||
 | 
					 		.data = &mtk_nfc_caps_mt2712,
 | 
				
			||||||
 | 
					+	}, {
 | 
				
			||||||
 | 
					+		.compatible = "mediatek,mt7622-nfc",
 | 
				
			||||||
 | 
					+		.data = &mtk_nfc_caps_mt7622,
 | 
				
			||||||
 | 
					 	},
 | 
				
			||||||
 | 
					 	{}
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					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(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/mmc/mtk-sd.txt b/Documentation/devicetree/bindings/mmc/mtk-sd.txt
 | 
				
			||||||
 | 
					index 72d2a734ab85..9b8017670870 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,377 @@
 | 
				
			|||||||
 | 
					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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt7622.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt7622.txt
 | 
				
			||||||
 | 
					new file mode 100644
 | 
				
			||||||
 | 
					index 000000000000..f18ed99f6e14
 | 
				
			||||||
 | 
					--- /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;
 | 
				
			||||||
 | 
					+			};
 | 
				
			||||||
 | 
					+		};
 | 
				
			||||||
 | 
					+	};
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
 | 
				
			||||||
 | 
					index fac9866311f3..03b3023d5fe5 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -0,0 +1,228 @@
 | 
				
			|||||||
 | 
					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(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
 | 
				
			||||||
 | 
					index 59dc0aad553c..7338f816c603 100644
 | 
				
			||||||
 | 
					--- 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
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					From 3f963310151f6e630f94acf73ff44493619038ff Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 20 Dec 2017 14:42:59 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 173/224] clk: mediatek: fixup test-building of MediaTek clock
 | 
				
			||||||
 | 
					 drivers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Let the build system looking into the directiory where the clock drivers
 | 
				
			||||||
 | 
					resides for the COMPILE_TEST alternative dependency allows test-building
 | 
				
			||||||
 | 
					the drivers.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/clk/Makefile | 2 +-
 | 
				
			||||||
 | 
					 1 file changed, 1 insertion(+), 1 deletion(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
 | 
				
			||||||
 | 
					index c99f363826f0..838000f92b69 100644
 | 
				
			||||||
 | 
					--- a/drivers/clk/Makefile
 | 
				
			||||||
 | 
					+++ b/drivers/clk/Makefile
 | 
				
			||||||
 | 
					@@ -66,7 +66,7 @@ obj-$(CONFIG_ARCH_MXC)			+= imx/
 | 
				
			||||||
 | 
					 obj-$(CONFIG_MACH_INGENIC)		+= ingenic/
 | 
				
			||||||
 | 
					 obj-$(CONFIG_ARCH_KEYSTONE)		+= keystone/
 | 
				
			||||||
 | 
					 obj-$(CONFIG_MACH_LOONGSON32)		+= loongson1/
 | 
				
			||||||
 | 
					-obj-$(CONFIG_ARCH_MEDIATEK)		+= mediatek/
 | 
				
			||||||
 | 
					+obj-y					+= mediatek/
 | 
				
			||||||
 | 
					 obj-$(CONFIG_COMMON_CLK_AMLOGIC)	+= meson/
 | 
				
			||||||
 | 
					 obj-$(CONFIG_MACH_PIC32)		+= microchip/
 | 
				
			||||||
 | 
					 ifeq ($(CONFIG_COMMON_CLK), y)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					From ee687ebf4708fb9e2a64830cdecd8cf992ef9b2b Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 20 Dec 2017 17:47:05 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 174/224] dt-bindings: net: mediatek: add condition to property
 | 
				
			||||||
 | 
					 mediatek, pctl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The property "mediatek,pctl" is only required for SoCs such as MT2701 and
 | 
				
			||||||
 | 
					MT7623, so adding a few words for stating the condition.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Reviewed-by: Rob Herring <robh@kernel.org>
 | 
				
			||||||
 | 
					Signed-off-by: David S. Miller <davem@davemloft.net>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 Documentation/devicetree/bindings/net/mediatek-net.txt | 2 +-
 | 
				
			||||||
 | 
					 1 file changed, 1 insertion(+), 1 deletion(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/net/mediatek-net.txt b/Documentation/devicetree/bindings/net/mediatek-net.txt
 | 
				
			||||||
 | 
					index 214eaa9a6683..53c13ee384a4 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/net/mediatek-net.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/net/mediatek-net.txt
 | 
				
			||||||
 | 
					@@ -28,7 +28,7 @@ Required properties:
 | 
				
			||||||
 | 
					 - mediatek,sgmiisys: phandle to the syscon node that handles the SGMII setup
 | 
				
			||||||
 | 
					 	which is required for those SoCs equipped with SGMII such as MT7622 SoC.
 | 
				
			||||||
 | 
					 - mediatek,pctl: phandle to the syscon node that handles the ports slew rate
 | 
				
			||||||
 | 
					-	and driver current
 | 
				
			||||||
 | 
					+	and driver current: only for MT2701 and MT7623 SoC
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Optional properties:
 | 
				
			||||||
 | 
					 - interrupt-parent: Should be the phandle for the interrupt controller
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,106 @@
 | 
				
			|||||||
 | 
					From d96cf7e724105dc73f623c2019ab5bc78cef036e Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 20 Dec 2017 17:47:06 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 175/224] net: mediatek: remove superfluous pin setup for
 | 
				
			||||||
 | 
					 MT7622 SoC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Remove superfluous pin setup to get out of accessing invalid I/O pin
 | 
				
			||||||
 | 
					registers because the way for pin configuring tends to be different from
 | 
				
			||||||
 | 
					various SoCs and thus it should be better being managed and controlled by
 | 
				
			||||||
 | 
					the pinctrl driver which MT7622 already can support.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: David S. Miller <davem@davemloft.net>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 35 +++++++++++++++++------------
 | 
				
			||||||
 | 
					 drivers/net/ethernet/mediatek/mtk_eth_soc.h |  3 +++
 | 
				
			||||||
 | 
					 2 files changed, 24 insertions(+), 14 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Index: linux-4.14.37/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | 
				
			||||||
 | 
					===================================================================
 | 
				
			||||||
 | 
					--- linux-4.14.37.orig/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | 
				
			||||||
 | 
					+++ linux-4.14.37/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 | 
				
			||||||
 | 
					@@ -1976,14 +1976,16 @@ static int mtk_hw_init(struct mtk_eth *e
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 	regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set GE2 driving and slew rate */
 | 
				
			||||||
 | 
					-	regmap_write(eth->pctl, GPIO_DRV_SEL10, 0xa00);
 | 
				
			||||||
 | 
					+	if (eth->pctl) {
 | 
				
			||||||
 | 
					+		/* Set GE2 driving and slew rate */
 | 
				
			||||||
 | 
					+		regmap_write(eth->pctl, GPIO_DRV_SEL10, 0xa00);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* set GE2 TDSEL */
 | 
				
			||||||
 | 
					-	regmap_write(eth->pctl, GPIO_OD33_CTRL8, 0x5);
 | 
				
			||||||
 | 
					+		/* set GE2 TDSEL */
 | 
				
			||||||
 | 
					+		regmap_write(eth->pctl, GPIO_OD33_CTRL8, 0x5);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* set GE2 TUNE */
 | 
				
			||||||
 | 
					-	regmap_write(eth->pctl, GPIO_BIAS_CTRL, 0x0);
 | 
				
			||||||
 | 
					+		/* set GE2 TUNE */
 | 
				
			||||||
 | 
					+		regmap_write(eth->pctl, GPIO_BIAS_CTRL, 0x0);
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* Set linkdown as the default for each GMAC. Its own MCR would be set
 | 
				
			||||||
 | 
					 	 * up with the more appropriate value when mtk_phy_link_adjust call is
 | 
				
			||||||
 | 
					@@ -2568,11 +2570,13 @@ static int mtk_probe(struct platform_dev
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	eth->pctl = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
 | 
				
			||||||
 | 
					-						    "mediatek,pctl");
 | 
				
			||||||
 | 
					-	if (IS_ERR(eth->pctl)) {
 | 
				
			||||||
 | 
					-		dev_err(&pdev->dev, "no pctl regmap found\n");
 | 
				
			||||||
 | 
					-		return PTR_ERR(eth->pctl);
 | 
				
			||||||
 | 
					+	if (eth->soc->required_pctl) {
 | 
				
			||||||
 | 
					+		eth->pctl = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
 | 
				
			||||||
 | 
					+							    "mediatek,pctl");
 | 
				
			||||||
 | 
					+		if (IS_ERR(eth->pctl)) {
 | 
				
			||||||
 | 
					+			dev_err(&pdev->dev, "no pctl regmap found\n");
 | 
				
			||||||
 | 
					+			return PTR_ERR(eth->pctl);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	for (i = 0; i < 3; i++) {
 | 
				
			||||||
 | 
					@@ -2698,17 +2702,20 @@ static int mtk_remove(struct platform_de
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct mtk_soc_data mt2701_data = {
 | 
				
			||||||
 | 
					 	.caps = MTK_GMAC1_TRGMII,
 | 
				
			||||||
 | 
					-	.required_clks = MT7623_CLKS_BITMAP
 | 
				
			||||||
 | 
					+	.required_clks = MT7623_CLKS_BITMAP,
 | 
				
			||||||
 | 
					+	.required_pctl = true,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct mtk_soc_data mt7622_data = {
 | 
				
			||||||
 | 
					 	.caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW,
 | 
				
			||||||
 | 
					-	.required_clks = MT7622_CLKS_BITMAP
 | 
				
			||||||
 | 
					+	.required_clks = MT7622_CLKS_BITMAP,
 | 
				
			||||||
 | 
					+	.required_pctl = false,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct mtk_soc_data mt7623_data = {
 | 
				
			||||||
 | 
					 	.caps = MTK_GMAC1_TRGMII,
 | 
				
			||||||
 | 
					-	.required_clks = MT7623_CLKS_BITMAP
 | 
				
			||||||
 | 
					+	.required_clks = MT7623_CLKS_BITMAP,
 | 
				
			||||||
 | 
					+	.required_pctl = true,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 const struct of_device_id of_mtk_match[] = {
 | 
				
			||||||
 | 
					Index: linux-4.14.37/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | 
				
			||||||
 | 
					===================================================================
 | 
				
			||||||
 | 
					--- linux-4.14.37.orig/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | 
				
			||||||
 | 
					+++ linux-4.14.37/drivers/net/ethernet/mediatek/mtk_eth_soc.h
 | 
				
			||||||
 | 
					@@ -574,10 +574,13 @@ struct mtk_rx_ring {
 | 
				
			||||||
 | 
					  * @caps			Flags shown the extra capability for the SoC
 | 
				
			||||||
 | 
					  * @required_clks		Flags shown the bitmap for required clocks on
 | 
				
			||||||
 | 
					  *				the target SoC
 | 
				
			||||||
 | 
					+ * @required_pctl		A bool value to show whether the SoC requires
 | 
				
			||||||
 | 
					+ *				the extra setup for those pins used by GMAC.
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					 struct mtk_soc_data {
 | 
				
			||||||
 | 
					 	u32		caps;
 | 
				
			||||||
 | 
					 	u32		required_clks;
 | 
				
			||||||
 | 
					+	bool		required_pctl;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* currently no SoC has more than 2 macs */
 | 
				
			||||||
@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					From f42f141077a12e28fe33c0033f698afb1402ec20 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Mon, 25 Dec 2017 16:03:57 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 176/224] clk: mediatek: Fix all warnings for missing struct
 | 
				
			||||||
 | 
					 clk_onecell_data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Even though the header file linux/clk-provider.h is already being properly
 | 
				
			||||||
 | 
					included in clk-mtk.h, the definition of struct clk_onecell_data still
 | 
				
			||||||
 | 
					must depend on CONFIG_COMMON_CLK defined and thus it's possible that
 | 
				
			||||||
 | 
					below build warnings occur when CONFIG_COMMON_CLK is not being selected.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Therefore, these functions which need struct clk_onecell_data without
 | 
				
			||||||
 | 
					declaring that structure first requires simply declaring that this struct
 | 
				
			||||||
 | 
					exists prior to referencing it in clk-mtk.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Changes from v1->v2:
 | 
				
			||||||
 | 
					enhance v1 based on two useful solutions Jean Delvare kindly suggested.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					All warnings (new ones prefixed by >>):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					In file included from drivers/clk/mediatek/reset.c:22:0:
 | 
				
			||||||
 | 
					>>drivers/clk/mediatek/clk-mtk.h:44:19: warning: 'struct clk_onecell_data'
 | 
				
			||||||
 | 
					declared inside parameter list will not be visible outside of
 | 
				
			||||||
 | 
					this definition or declaration
 | 
				
			||||||
 | 
					  int num, struct clk_onecell_data *clk_data);
 | 
				
			||||||
 | 
							  ^~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					drivers/clk/mediatek/clk-mtk.h:63:19: warning: 'struct clk_onecell_data'
 | 
				
			||||||
 | 
					declared inside parameter list will not be visible outside of
 | 
				
			||||||
 | 
					this definition or declaration
 | 
				
			||||||
 | 
					  int num, struct clk_onecell_data *clk_data);
 | 
				
			||||||
 | 
							  ^~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					drivers/clk/mediatek/clk-mtk.h:145:10: warning: 'struct clk_onecell_data'
 | 
				
			||||||
 | 
					declared inside parameter list will not be visible outside of
 | 
				
			||||||
 | 
					this definition or declaration
 | 
				
			||||||
 | 
					  struct clk_onecell_data *clk_data);
 | 
				
			||||||
 | 
						 ^~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					drivers/clk/mediatek/clk-mtk.h:164:11: warning: 'struct clk_onecell_data'
 | 
				
			||||||
 | 
					declared inside parameter list will not be visible outside of
 | 
				
			||||||
 | 
					this definition or declaration
 | 
				
			||||||
 | 
					   struct clk_onecell_data *clk_data);
 | 
				
			||||||
 | 
						  ^~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					drivers/clk/mediatek/clk-mtk.h:190:12: warning: 'struct clk_onecell_data'
 | 
				
			||||||
 | 
					declared inside parameter list will not be visible outside of this
 | 
				
			||||||
 | 
					definition or declaration
 | 
				
			||||||
 | 
					    struct clk_onecell_data *clk_data);
 | 
				
			||||||
 | 
						   ^~~~~~~~~~~~~~~~
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Reported-by: kbuild test robot <fengguang.wu@intel.com>
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Cc: kbuild-all@01.org
 | 
				
			||||||
 | 
					Cc: Stephen Boyd <sboyd@codeaurora.org>
 | 
				
			||||||
 | 
					Cc: Jean Delvare <jdelvare@suse.de>
 | 
				
			||||||
 | 
					Cc: linux-clk@vger.kernel.org
 | 
				
			||||||
 | 
					Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/clk/mediatek/clk-mtk.h | 1 +
 | 
				
			||||||
 | 
					 1 file changed, 1 insertion(+)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					index f10250dcece4..bf8006d41861 100644
 | 
				
			||||||
 | 
					--- a/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					+++ b/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					@@ -20,6 +20,7 @@
 | 
				
			||||||
 | 
					 #include <linux/clk-provider.h>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 struct clk;
 | 
				
			||||||
 | 
					+struct clk_onecell_data;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #define MAX_MUX_GATE_BIT	31
 | 
				
			||||||
 | 
					 #define INVALID_MUX_GATE_BIT	(MAX_MUX_GATE_BIT + 1)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,80 @@
 | 
				
			|||||||
 | 
					From dacdae142ffd909ed6718adb05af74ff800da668 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 7 Dec 2017 19:53:34 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 177/224] phy: phy-mtk-tphy: use auto instead of force to
 | 
				
			||||||
 | 
					 bypass utmi signals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					When system is running, if usb2 phy is forced to bypass utmi signals,
 | 
				
			||||||
 | 
					all PLL will be turned off, and it can't detect device connection
 | 
				
			||||||
 | 
					anymore, so replace force mode with auto mode which can bypass utmi
 | 
				
			||||||
 | 
					signals automatically if no device attached for normal flow.
 | 
				
			||||||
 | 
					But keep the force mode to fix RX sensitivity degradation issue.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 | 19 +++++++------------
 | 
				
			||||||
 | 
					 1 file changed, 7 insertions(+), 12 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					index 402385f2562a..54cc44b2d289 100644
 | 
				
			||||||
 | 
					--- a/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					@@ -440,9 +440,9 @@ static void u2_phy_instance_init(struct mtk_tphy *tphy,
 | 
				
			||||||
 | 
					 	u32 index = instance->index;
 | 
				
			||||||
 | 
					 	u32 tmp;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* switch to USB function. (system register, force ip into usb mode) */
 | 
				
			||||||
 | 
					+	/* switch to USB function, and enable usb pll */
 | 
				
			||||||
 | 
					 	tmp = readl(com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					-	tmp &= ~P2C_FORCE_UART_EN;
 | 
				
			||||||
 | 
					+	tmp &= ~(P2C_FORCE_UART_EN | P2C_FORCE_SUSPENDM);
 | 
				
			||||||
 | 
					 	tmp |= P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0);
 | 
				
			||||||
 | 
					 	writel(tmp, com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -502,10 +502,8 @@ static void u2_phy_instance_power_on(struct mtk_tphy *tphy,
 | 
				
			||||||
 | 
					 	u32 index = instance->index;
 | 
				
			||||||
 | 
					 	u32 tmp;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* (force_suspendm=0) (let suspendm=1, enable usb 480MHz pll) */
 | 
				
			||||||
 | 
					 	tmp = readl(com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					-	tmp &= ~(P2C_FORCE_SUSPENDM | P2C_RG_XCVRSEL);
 | 
				
			||||||
 | 
					-	tmp &= ~(P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
 | 
				
			||||||
 | 
					+	tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
 | 
				
			||||||
 | 
					 	writel(tmp, com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* OTG Enable */
 | 
				
			||||||
 | 
					@@ -540,7 +538,6 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	tmp = readl(com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					 	tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN);
 | 
				
			||||||
 | 
					-	tmp |= P2C_FORCE_SUSPENDM;
 | 
				
			||||||
 | 
					 	writel(tmp, com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* OTG Disable */
 | 
				
			||||||
 | 
					@@ -548,18 +545,16 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
 | 
				
			||||||
 | 
					 	tmp &= ~PA6_RG_U2_OTG_VBUSCMP_EN;
 | 
				
			||||||
 | 
					 	writel(tmp, com + U3P_USBPHYACR6);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* let suspendm=0, set utmi into analog power down */
 | 
				
			||||||
 | 
					-	tmp = readl(com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					-	tmp &= ~P2C_RG_SUSPENDM;
 | 
				
			||||||
 | 
					-	writel(tmp, com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					-	udelay(1);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	tmp = readl(com + U3P_U2PHYDTM1);
 | 
				
			||||||
 | 
					 	tmp &= ~(P2C_RG_VBUSVALID | P2C_RG_AVALID);
 | 
				
			||||||
 | 
					 	tmp |= P2C_RG_SESSEND;
 | 
				
			||||||
 | 
					 	writel(tmp, com + U3P_U2PHYDTM1);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	if (tphy->pdata->avoid_rx_sen_degradation && index) {
 | 
				
			||||||
 | 
					+		tmp = readl(com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					+		tmp &= ~(P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM);
 | 
				
			||||||
 | 
					+		writel(tmp, com + U3P_U2PHYDTM0);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 		tmp = readl(com + U3D_U2PHYDCR0);
 | 
				
			||||||
 | 
					 		tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON;
 | 
				
			||||||
 | 
					 		writel(tmp, com + U3D_U2PHYDCR0);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					From d7a38584713b00cf9ae97aed89d5e8fb7e3c1bea Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 7 Dec 2017 19:53:35 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 178/224] phy: phy-mtk-tphy: make shared banks optional for V1
 | 
				
			||||||
 | 
					 TPHY
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					V1 TPHY for SATA doesn't have shared banks if it isn't shared
 | 
				
			||||||
 | 
					with PCIe or USB, so make it optional.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 | 5 +++--
 | 
				
			||||||
 | 
					 1 file changed, 3 insertions(+), 2 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					index 54cc44b2d289..11cab1d84a02 100644
 | 
				
			||||||
 | 
					--- a/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					@@ -1023,9 +1023,10 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	tphy->dev = dev;
 | 
				
			||||||
 | 
					 	platform_set_drvdata(pdev, tphy);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	if (tphy->pdata->version == MTK_PHY_V1) {
 | 
				
			||||||
 | 
					+	sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | 
				
			||||||
 | 
					+	/* SATA phy of V1 needn't it if not shared with PCIe or USB */
 | 
				
			||||||
 | 
					+	if (sif_res && tphy->pdata->version == MTK_PHY_V1) {
 | 
				
			||||||
 | 
					 		/* get banks shared by multiple phys */
 | 
				
			||||||
 | 
					-		sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | 
				
			||||||
 | 
					 		tphy->sif_base = devm_ioremap_resource(dev, sif_res);
 | 
				
			||||||
 | 
					 		if (IS_ERR(tphy->sif_base)) {
 | 
				
			||||||
 | 
					 			dev_err(dev, "failed to remap sif regs\n");
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					From 3e53007a55e70d5036a527900befecf9a6316d05 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 28 Dec 2017 16:40:36 +0530
 | 
				
			||||||
 | 
					Subject: [PATCH 179/224] phy: phy-mtk-tphy: use of_device_get_match_data()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					reduce the boilerplate code to get the specific data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 | 11 +++++------
 | 
				
			||||||
 | 
					 1 file changed, 5 insertions(+), 6 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					index 11cab1d84a02..1e96d0740ef5 100644
 | 
				
			||||||
 | 
					--- a/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
 | 
				
			||||||
 | 
					@@ -20,6 +20,7 @@
 | 
				
			||||||
 | 
					 #include <linux/iopoll.h>
 | 
				
			||||||
 | 
					 #include <linux/module.h>
 | 
				
			||||||
 | 
					 #include <linux/of_address.h>
 | 
				
			||||||
 | 
					+#include <linux/of_device.h>
 | 
				
			||||||
 | 
					 #include <linux/phy/phy.h>
 | 
				
			||||||
 | 
					 #include <linux/platform_device.h>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -995,7 +996,6 @@ MODULE_DEVICE_TABLE(of, mtk_tphy_id_table);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mtk_tphy_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	const struct of_device_id *match;
 | 
				
			||||||
 | 
					 	struct device *dev = &pdev->dev;
 | 
				
			||||||
 | 
					 	struct device_node *np = dev->of_node;
 | 
				
			||||||
 | 
					 	struct device_node *child_np;
 | 
				
			||||||
 | 
					@@ -1005,15 +1005,14 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	struct resource res;
 | 
				
			||||||
 | 
					 	int port, retval;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	match = of_match_node(mtk_tphy_id_table, pdev->dev.of_node);
 | 
				
			||||||
 | 
					-	if (!match)
 | 
				
			||||||
 | 
					-		return -EINVAL;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL);
 | 
				
			||||||
 | 
					 	if (!tphy)
 | 
				
			||||||
 | 
					 		return -ENOMEM;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	tphy->pdata = match->data;
 | 
				
			||||||
 | 
					+	tphy->pdata = of_device_get_match_data(dev);
 | 
				
			||||||
 | 
					+	if (!tphy->pdata)
 | 
				
			||||||
 | 
					+		return -EINVAL;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	tphy->nphys = of_get_child_count(np);
 | 
				
			||||||
 | 
					 	tphy->phys = devm_kcalloc(dev, tphy->nphys,
 | 
				
			||||||
 | 
					 				       sizeof(*tphy->phys), GFP_KERNEL);
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,86 @@
 | 
				
			|||||||
 | 
					From 17508c32dd65649d2617c1c52b32b02bdb54b793 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Tue, 2 Jan 2018 19:47:18 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 180/224] ASoC: mediatek: fix error handling in
 | 
				
			||||||
 | 
					 mt2701_afe_pcm_dev_probe()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Fix unbalanced error handling path which will get incorrect counts
 | 
				
			||||||
 | 
					if probe failed. The .remove() should be adjusted accordingly.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Tested-by: Garlic Tseng <garlic.tseng@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 31 ++++++++++++++----------------
 | 
				
			||||||
 | 
					 1 file changed, 14 insertions(+), 17 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					index 8fda182f849b..a7362d1cda1b 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					@@ -1590,12 +1590,16 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	platform_set_drvdata(pdev, afe);
 | 
				
			||||||
 | 
					-	pm_runtime_enable(&pdev->dev);
 | 
				
			||||||
 | 
					-	if (!pm_runtime_enabled(&pdev->dev))
 | 
				
			||||||
 | 
					-		goto err_pm_disable;
 | 
				
			||||||
 | 
					-	pm_runtime_get_sync(&pdev->dev);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform);
 | 
				
			||||||
 | 
					+	pm_runtime_enable(dev);
 | 
				
			||||||
 | 
					+	if (!pm_runtime_enabled(dev)) {
 | 
				
			||||||
 | 
					+		ret = mt2701_afe_runtime_resume(dev);
 | 
				
			||||||
 | 
					+		if (ret)
 | 
				
			||||||
 | 
					+			goto err_pm_disable;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					+	pm_runtime_get_sync(dev);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform);
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					 		dev_warn(dev, "err_platform\n");
 | 
				
			||||||
 | 
					 		goto err_platform;
 | 
				
			||||||
 | 
					@@ -1610,35 +1614,28 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 		goto err_dai_component;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	mt2701_afe_runtime_resume(&pdev->dev);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 err_dai_component:
 | 
				
			||||||
 | 
					-	snd_soc_unregister_component(&pdev->dev);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+	snd_soc_unregister_platform(dev);
 | 
				
			||||||
 | 
					 err_platform:
 | 
				
			||||||
 | 
					-	snd_soc_unregister_platform(&pdev->dev);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+	pm_runtime_put_sync(dev);
 | 
				
			||||||
 | 
					 err_pm_disable:
 | 
				
			||||||
 | 
					-	pm_runtime_disable(&pdev->dev);
 | 
				
			||||||
 | 
					+	pm_runtime_disable(dev);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return ret;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct mtk_base_afe *afe = platform_get_drvdata(pdev);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					+	pm_runtime_put_sync(&pdev->dev);
 | 
				
			||||||
 | 
					 	pm_runtime_disable(&pdev->dev);
 | 
				
			||||||
 | 
					 	if (!pm_runtime_status_suspended(&pdev->dev))
 | 
				
			||||||
 | 
					 		mt2701_afe_runtime_suspend(&pdev->dev);
 | 
				
			||||||
 | 
					-	pm_runtime_put_sync(&pdev->dev);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	snd_soc_unregister_component(&pdev->dev);
 | 
				
			||||||
 | 
					 	snd_soc_unregister_platform(&pdev->dev);
 | 
				
			||||||
 | 
					-	/* disable afe clock */
 | 
				
			||||||
 | 
					-	mt2701_afe_disable_clock(afe);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,932 @@
 | 
				
			|||||||
 | 
					From d038da516563d910dd39930777f431d4c65a56cd Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Tue, 2 Jan 2018 19:47:19 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 181/224] ASoC: mediatek: rework clock functions for MT2701
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Reworks clock part to make it more reasonable. The current changes are:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Replace regmap operations by CCF APIs. Doing so, we just need to handle
 | 
				
			||||||
 | 
					  the element clocks and can also get accurate information via CCF.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Rename clocks to make them more generic so that the future revisions
 | 
				
			||||||
 | 
					  of the IP can adapt gracefully.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Regroup 'aud_clks[]' by usage - the basic needs and I2S parts:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  The new code just keep the common clocks in array and let SoC self decide
 | 
				
			||||||
 | 
					  I2S numbers - If future chips have different sets of channels we will
 | 
				
			||||||
 | 
					  add a little more abstract here.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Moreover, this patch moves I2S clocks to the struct mt2701_i2s_data
 | 
				
			||||||
 | 
					  so that we can easily manage them when calls .prepare() and .shutdown().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Tested-by: Garlic Tseng <garlic.tseng@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c | 518 +++++++---------------
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.h |  15 +-
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-common.h     |  64 +--
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c        |  45 +-
 | 
				
			||||||
 | 
					 4 files changed, 200 insertions(+), 442 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					index affa7fb25dd9..75ccdca5811d 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					@@ -21,442 +21,256 @@
 | 
				
			||||||
 | 
					 #include "mt2701-afe-common.h"
 | 
				
			||||||
 | 
					 #include "mt2701-afe-clock-ctrl.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static const char *aud_clks[MT2701_CLOCK_NUM] = {
 | 
				
			||||||
 | 
					-	[MT2701_AUD_INFRA_SYS_AUDIO] = "infra_sys_audio_clk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_MUX1_SEL] = "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_MUX2_SEL] = "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_MUX1_DIV] = "top_audio_mux1_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_MUX2_DIV] = "top_audio_mux2_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_48K_TIMING] = "top_audio_48k_timing",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_44K_TIMING] = "top_audio_44k_timing",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL_MUX_SEL] = "top_audpll_mux_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_APLL_SEL] = "top_apll_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD1PLL_98M] = "top_aud1_pll_98M",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD2PLL_90M] = "top_aud2_pll_90M",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_HADDS2PLL_98M] = "top_hadds2_pll_98M",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_HADDS2PLL_294M] = "top_hadds2_pll_294M",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL] = "top_audpll",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL_D4] = "top_audpll_d4",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL_D8] = "top_audpll_d8",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL_D16] = "top_audpll_d16",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDPLL_D24] = "top_audpll_d24",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUDINTBUS] = "top_audintbus_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_CLK_26M] = "clk_26m",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_SYSPLL1_D4] = "top_syspll1_d4",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K1_SRC_SEL] = "top_aud_k1_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K2_SRC_SEL] = "top_aud_k2_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K3_SRC_SEL] = "top_aud_k3_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K4_SRC_SEL] = "top_aud_k4_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K5_SRC_SEL] = "top_aud_k5_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K6_SRC_SEL] = "top_aud_k6_src_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K1_SRC_DIV] = "top_aud_k1_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K2_SRC_DIV] = "top_aud_k2_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K3_SRC_DIV] = "top_aud_k3_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K4_SRC_DIV] = "top_aud_k4_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K5_SRC_DIV] = "top_aud_k5_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_K6_SRC_DIV] = "top_aud_k6_src_div",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S1_MCLK] = "top_aud_i2s1_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S2_MCLK] = "top_aud_i2s2_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S3_MCLK] = "top_aud_i2s3_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S4_MCLK] = "top_aud_i2s4_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S5_MCLK] = "top_aud_i2s5_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_AUD_I2S6_MCLK] = "top_aud_i2s6_mclk",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_ASM_M_SEL] = "top_asm_m_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_ASM_H_SEL] = "top_asm_h_sel",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_UNIVPLL2_D4] = "top_univpll2_d4",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_UNIVPLL2_D2] = "top_univpll2_d2",
 | 
				
			||||||
 | 
					-	[MT2701_AUD_SYSPLL_D5] = "top_syspll_d5",
 | 
				
			||||||
 | 
					+static const char *const base_clks[] = {
 | 
				
			||||||
 | 
					+	[MT2701_TOP_AUD_MCLK_SRC0] = "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					+	[MT2701_TOP_AUD_MCLK_SRC1] = "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					+	[MT2701_AUDSYS_AFE] = "audio_afe_pd",
 | 
				
			||||||
 | 
					+	[MT2701_AUDSYS_AFE_CONN] = "audio_afe_conn_pd",
 | 
				
			||||||
 | 
					+	[MT2701_AUDSYS_A1SYS] = "audio_a1sys_pd",
 | 
				
			||||||
 | 
					+	[MT2701_AUDSYS_A2SYS] = "audio_a2sys_pd",
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 int mt2701_init_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					-	int i = 0;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	for (i = 0; i < MT2701_CLOCK_NUM; i++) {
 | 
				
			||||||
 | 
					-		afe_priv->clocks[i] = devm_clk_get(afe->dev, aud_clks[i]);
 | 
				
			||||||
 | 
					-		if (IS_ERR(afe_priv->clocks[i])) {
 | 
				
			||||||
 | 
					-			dev_warn(afe->dev, "%s devm_clk_get %s fail\n",
 | 
				
			||||||
 | 
					-				 __func__, aud_clks[i]);
 | 
				
			||||||
 | 
					-			return PTR_ERR(aud_clks[i]);
 | 
				
			||||||
 | 
					+	int i;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	for (i = 0; i < MT2701_BASE_CLK_NUM; i++) {
 | 
				
			||||||
 | 
					+		afe_priv->base_ck[i] = devm_clk_get(afe->dev, base_clks[i]);
 | 
				
			||||||
 | 
					+		if (IS_ERR(afe_priv->base_ck[i])) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", base_clks[i]);
 | 
				
			||||||
 | 
					+			return PTR_ERR(afe_priv->base_ck[i]);
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+	/* Get I2S related clocks */
 | 
				
			||||||
 | 
					+	for (i = 0; i < MT2701_I2S_NUM; i++) {
 | 
				
			||||||
 | 
					+		struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i];
 | 
				
			||||||
 | 
					+		char name[13];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	int ret = 0;
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "i2s%d_src_sel", i);
 | 
				
			||||||
 | 
					+		i2s_path->sel_ck = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->sel_ck)) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->sel_ck);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = mt2701_turn_on_a1sys_clock(afe);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s turn_on_a1sys_clock fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, ret);
 | 
				
			||||||
 | 
					-		return ret;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "i2s%d_src_div", i);
 | 
				
			||||||
 | 
					+		i2s_path->div_ck = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->div_ck)) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->div_ck);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = mt2701_turn_on_a2sys_clock(afe);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s turn_on_a2sys_clock fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, ret);
 | 
				
			||||||
 | 
					-		mt2701_turn_off_a1sys_clock(afe);
 | 
				
			||||||
 | 
					-		return ret;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "i2s%d_mclk_en", i);
 | 
				
			||||||
 | 
					+		i2s_path->mclk_ck = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->mclk_ck)) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->mclk_ck);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = mt2701_turn_on_afe_clock(afe);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s turn_on_afe_clock fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, ret);
 | 
				
			||||||
 | 
					-		mt2701_turn_off_a1sys_clock(afe);
 | 
				
			||||||
 | 
					-		mt2701_turn_off_a2sys_clock(afe);
 | 
				
			||||||
 | 
					-		return ret;
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "i2so%d_hop_ck", i);
 | 
				
			||||||
 | 
					+		i2s_path->hop_ck[I2S_OUT] = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->hop_ck[I2S_OUT])) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->hop_ck[I2S_OUT]);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "i2si%d_hop_ck", i);
 | 
				
			||||||
 | 
					+		i2s_path->hop_ck[I2S_IN] = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->hop_ck[I2S_IN])) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->hop_ck[I2S_IN]);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+		snprintf(name, sizeof(name), "asrc%d_out_ck", i);
 | 
				
			||||||
 | 
					+		i2s_path->asrco_ck = devm_clk_get(afe->dev, name);
 | 
				
			||||||
 | 
					+		if (IS_ERR(i2s_path->asrco_ck)) {
 | 
				
			||||||
 | 
					+			dev_err(afe->dev, "failed to get %s\n", name);
 | 
				
			||||||
 | 
					+			return PTR_ERR(i2s_path->asrco_ck);
 | 
				
			||||||
 | 
					+		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					-			   AFE_DAC_CON0_AFE_ON,
 | 
				
			||||||
 | 
					-			   AFE_DAC_CON0_AFE_ON);
 | 
				
			||||||
 | 
					-	regmap_write(afe->regmap, PWR2_TOP_CON,
 | 
				
			||||||
 | 
					-		     PWR2_TOP_CON_INIT_VAL);
 | 
				
			||||||
 | 
					-	regmap_write(afe->regmap, PWR1_ASM_CON1,
 | 
				
			||||||
 | 
					-		     PWR1_ASM_CON1_INIT_VAL);
 | 
				
			||||||
 | 
					-	regmap_write(afe->regmap, PWR2_ASM_CON1,
 | 
				
			||||||
 | 
					-		     PWR2_ASM_CON1_INIT_VAL);
 | 
				
			||||||
 | 
					+	/* Some platforms may support BT path */
 | 
				
			||||||
 | 
					+	afe_priv->mrgif_ck = devm_clk_get(afe->dev, "audio_mrgif_pd");
 | 
				
			||||||
 | 
					+	if (IS_ERR(afe_priv->mrgif_ck)) {
 | 
				
			||||||
 | 
					+		if (PTR_ERR(afe_priv->mrgif_ck) == -EPROBE_DEFER)
 | 
				
			||||||
 | 
					+			return -EPROBE_DEFER;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+		afe_priv->mrgif_ck = NULL;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-void mt2701_afe_disable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	mt2701_turn_off_afe_clock(afe);
 | 
				
			||||||
 | 
					-	mt2701_turn_off_a1sys_clock(afe);
 | 
				
			||||||
 | 
					-	mt2701_turn_off_a2sys_clock(afe);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					-			   AFE_DAC_CON0_AFE_ON, 0);
 | 
				
			||||||
 | 
					+	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_turn_on_a1sys_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+int mt2701_afe_enable_i2s(struct mtk_base_afe *afe, int id, int dir)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					-	int ret = 0;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[id];
 | 
				
			||||||
 | 
					+	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set Mux */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(i2s_path->asrco_ck);
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUD_MUX1_SEL], ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_AUD_MUX1_SEL_ERR;
 | 
				
			||||||
 | 
					+		dev_err(afe->dev, "failed to enable ASRC clock %d\n", ret);
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL],
 | 
				
			||||||
 | 
					-			     afe_priv->clocks[MT2701_AUD_AUD1PLL_98M]);
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(i2s_path->hop_ck[dir]);
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD_MUX1_SEL],
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD1PLL_98M], ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_AUD_MUX1_SEL_ERR;
 | 
				
			||||||
 | 
					+		dev_err(afe->dev, "failed to enable I2S clock %d\n", ret);
 | 
				
			||||||
 | 
					+		goto err_hop_ck;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set Divider */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD_MUX1_DIV],
 | 
				
			||||||
 | 
					-			ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_AUD_MUX1_DIV_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_rate(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV],
 | 
				
			||||||
 | 
					-			   MT2701_AUD_AUD_MUX1_DIV_RATE);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%d fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD_MUX1_DIV],
 | 
				
			||||||
 | 
					-			MT2701_AUD_AUD_MUX1_DIV_RATE, ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_AUD_MUX1_DIV_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+err_hop_ck:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(i2s_path->asrco_ck);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Enable clock gate */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUD_48K_TIMING], ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_AUD_48K_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	return ret;
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Enable infra audio */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
 | 
				
			||||||
 | 
					-		goto A1SYS_CLK_INFRA_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+void mt2701_afe_disable_i2s(struct mtk_base_afe *afe, int id, int dir)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[id];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(i2s_path->hop_ck[dir]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(i2s_path->asrco_ck);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-A1SYS_CLK_INFRA_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-A1SYS_CLK_AUD_48K_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
 | 
				
			||||||
 | 
					-A1SYS_CLK_AUD_MUX1_DIV_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
 | 
				
			||||||
 | 
					-A1SYS_CLK_AUD_MUX1_SEL_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
 | 
				
			||||||
 | 
					+int mt2701_afe_enable_mclk(struct mtk_base_afe *afe, int id)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[id];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return ret;
 | 
				
			||||||
 | 
					+	return clk_prepare_enable(i2s_path->mclk_ck);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-void mt2701_turn_off_a1sys_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+void mt2701_afe_disable_mclk(struct mtk_base_afe *afe, int id)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[id];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(i2s_path->mclk_ck);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_turn_on_a2sys_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+int mt2701_enable_btmrg_clk(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					-	int ret = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set Mux */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUD_MUX2_SEL], ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_AUD_MUX2_SEL_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	return clk_prepare_enable(afe_priv->mrgif_ck);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL],
 | 
				
			||||||
 | 
					-			     afe_priv->clocks[MT2701_AUD_AUD2PLL_90M]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD_MUX2_SEL],
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD2PLL_90M], ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_AUD_MUX2_SEL_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+void mt2701_disable_btmrg_clk(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set Divider */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUD_MUX2_DIV], ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_AUD_MUX2_DIV_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->mrgif_ck);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_rate(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV],
 | 
				
			||||||
 | 
					-			   MT2701_AUD_AUD_MUX2_DIV_RATE);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%d fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUD_MUX2_DIV],
 | 
				
			||||||
 | 
					-			MT2701_AUD_AUD_MUX2_DIV_RATE, ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_AUD_MUX2_DIV_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+static int mt2701_afe_enable_audsys(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Enable clock gate */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUD_44K_TIMING], ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_AUD_44K_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Enable infra audio */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
 | 
				
			||||||
 | 
					-		goto A2SYS_CLK_INFRA_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_audio_a1sys;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_A2SYS]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_audio_a2sys;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_AFE_CONN]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_afe_conn;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-A2SYS_CLK_INFRA_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-A2SYS_CLK_AUD_44K_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
 | 
				
			||||||
 | 
					-A2SYS_CLK_AUD_MUX2_DIV_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
 | 
				
			||||||
 | 
					-A2SYS_CLK_AUD_MUX2_SEL_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
 | 
				
			||||||
 | 
					+err_afe_conn:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A2SYS]);
 | 
				
			||||||
 | 
					+err_audio_a2sys:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					+err_audio_a1sys:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return ret;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-void mt2701_turn_off_a2sys_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+static void mt2701_afe_disable_audsys(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_AFE_CONN]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A2SYS]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_turn_on_afe_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* enable INFRA_SYS */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_INFRA_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* Set MT2701_AUD_AUDINTBUS to MT2701_AUD_SYSPLL1_D4 */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_AUDINTBUS], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_AUDINTBUS_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUDINTBUS],
 | 
				
			||||||
 | 
					-			     afe_priv->clocks[MT2701_AUD_SYSPLL1_D4]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_AUDINTBUS],
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_SYSPLL1_D4], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_AUDINTBUS_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* Set MT2701_AUD_ASM_H_SEL to MT2701_AUD_UNIVPLL2_D2 */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_ASM_H_SEL], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_ASM_H_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_ASM_H_SEL],
 | 
				
			||||||
 | 
					-			     afe_priv->clocks[MT2701_AUD_UNIVPLL2_D2]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_ASM_H_SEL],
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_UNIVPLL2_D2], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_ASM_H_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* Set MT2701_AUD_ASM_M_SEL to MT2701_AUD_UNIVPLL2_D4 */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
 | 
				
			||||||
 | 
					+	/* Enable audio system */
 | 
				
			||||||
 | 
					+	ret = mt2701_afe_enable_audsys(afe);
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[MT2701_AUD_ASM_M_SEL], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_ASM_M_ERR;
 | 
				
			||||||
 | 
					+		dev_err(afe->dev, "failed to enable audio system %d\n", ret);
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_ASM_M_SEL],
 | 
				
			||||||
 | 
					-			     afe_priv->clocks[MT2701_AUD_UNIVPLL2_D4]);
 | 
				
			||||||
 | 
					-	if (ret) {
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_ASM_M_SEL],
 | 
				
			||||||
 | 
					-			aud_clks[MT2701_AUD_UNIVPLL2_D4], ret);
 | 
				
			||||||
 | 
					-		goto AFE_AUD_ASM_M_ERR;
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					+			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON,
 | 
				
			||||||
 | 
					+			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON);
 | 
				
			||||||
 | 
					+	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					+			   AFE_DAC_CON0_AFE_ON,
 | 
				
			||||||
 | 
					+			   AFE_DAC_CON0_AFE_ON);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_PDN_AFE, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_PDN_APLL_CK, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A1SYS, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A2SYS, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_AFE_CONN, 0);
 | 
				
			||||||
 | 
					+	/* Configure ASRC */
 | 
				
			||||||
 | 
					+	regmap_write(afe->regmap, PWR1_ASM_CON1, PWR1_ASM_CON1_INIT_VAL);
 | 
				
			||||||
 | 
					+	regmap_write(afe->regmap, PWR2_ASM_CON1, PWR2_ASM_CON1_INIT_VAL);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-AFE_AUD_ASM_M_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
 | 
				
			||||||
 | 
					-AFE_AUD_ASM_H_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
 | 
				
			||||||
 | 
					-AFE_AUD_AUDINTBUS_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
 | 
				
			||||||
 | 
					-AFE_AUD_INFRA_ERR:
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	return ret;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-void mt2701_turn_off_afe_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					+int mt2701_afe_disable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					+			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON, 0);
 | 
				
			||||||
 | 
					+	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					+			   AFE_DAC_CON0_AFE_ON, 0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_PDN_AFE, AUDIO_TOP_CON0_PDN_AFE);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_PDN_APLL_CK,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_PDN_APLL_CK);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A1SYS,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A1SYS);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A2SYS,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_A2SYS);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_AFE_CONN,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_AFE_CONN);
 | 
				
			||||||
 | 
					+	mt2701_afe_disable_audsys(afe);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 void mt2701_mclk_configuration(struct mtk_base_afe *afe, int id, int domain,
 | 
				
			||||||
 | 
					 			       int mclk)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	struct mt2701_afe_private *priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &priv->i2s_path[id];
 | 
				
			||||||
 | 
					 	int ret;
 | 
				
			||||||
 | 
					-	int aud_src_div_id = MT2701_AUD_AUD_K1_SRC_DIV + id;
 | 
				
			||||||
 | 
					-	int aud_src_clk_id = MT2701_AUD_AUD_K1_SRC_SEL + id;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set MCLK Kx_SRC_SEL(domain) */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[aud_src_clk_id]);
 | 
				
			||||||
 | 
					-	if (ret)
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[aud_src_clk_id], ret);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	if (domain == 0) {
 | 
				
			||||||
 | 
					-		ret = clk_set_parent(afe_priv->clocks[aud_src_clk_id],
 | 
				
			||||||
 | 
					-				     afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
 | 
				
			||||||
 | 
					-		if (ret)
 | 
				
			||||||
 | 
					-			dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n",
 | 
				
			||||||
 | 
					-				__func__, aud_clks[aud_src_clk_id],
 | 
				
			||||||
 | 
					-				aud_clks[MT2701_AUD_AUD_MUX1_SEL], ret);
 | 
				
			||||||
 | 
					-	} else {
 | 
				
			||||||
 | 
					-		ret = clk_set_parent(afe_priv->clocks[aud_src_clk_id],
 | 
				
			||||||
 | 
					-				     afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
 | 
				
			||||||
 | 
					-		if (ret)
 | 
				
			||||||
 | 
					-			dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n",
 | 
				
			||||||
 | 
					-				__func__, aud_clks[aud_src_clk_id],
 | 
				
			||||||
 | 
					-				aud_clks[MT2701_AUD_AUD_MUX2_SEL], ret);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[aud_src_clk_id]);
 | 
				
			||||||
 | 
					+	/* Set mclk source */
 | 
				
			||||||
 | 
					+	if (domain == 0)
 | 
				
			||||||
 | 
					+		ret = clk_set_parent(i2s_path->sel_ck,
 | 
				
			||||||
 | 
					+				     priv->base_ck[MT2701_TOP_AUD_MCLK_SRC0]);
 | 
				
			||||||
 | 
					+	else
 | 
				
			||||||
 | 
					+		ret = clk_set_parent(i2s_path->sel_ck,
 | 
				
			||||||
 | 
					+				     priv->base_ck[MT2701_TOP_AUD_MCLK_SRC1]);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* Set MCLK Kx_SRC_DIV(divider) */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[aud_src_div_id]);
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
 | 
				
			||||||
 | 
					-			__func__, aud_clks[aud_src_div_id], ret);
 | 
				
			||||||
 | 
					+		dev_err(afe->dev, "failed to set domain%d mclk source %d\n",
 | 
				
			||||||
 | 
					+			domain, ret);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_set_rate(afe_priv->clocks[aud_src_div_id], mclk);
 | 
				
			||||||
 | 
					+	/* Set mclk divider */
 | 
				
			||||||
 | 
					+	ret = clk_set_rate(i2s_path->div_ck, mclk);
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "%s clk_set_rate %s-%d fail %d\n", __func__,
 | 
				
			||||||
 | 
					-			aud_clks[aud_src_div_id], mclk, ret);
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[aud_src_div_id]);
 | 
				
			||||||
 | 
					+		dev_err(afe->dev, "failed to set mclk divider %d\n", ret);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 MODULE_DESCRIPTION("MT2701 afe clock control");
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.h b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.h
 | 
				
			||||||
 | 
					index 6497d570cf09..15417d9d6597 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.h
 | 
				
			||||||
 | 
					@@ -21,16 +21,15 @@ struct mtk_base_afe;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 int mt2701_init_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					 int mt2701_afe_enable_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					-void mt2701_afe_disable_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					+int mt2701_afe_disable_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_turn_on_a1sys_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					-void mt2701_turn_off_a1sys_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					+int mt2701_afe_enable_i2s(struct mtk_base_afe *afe, int id, int dir);
 | 
				
			||||||
 | 
					+void mt2701_afe_disable_i2s(struct mtk_base_afe *afe, int id, int dir);
 | 
				
			||||||
 | 
					+int mt2701_afe_enable_mclk(struct mtk_base_afe *afe, int id);
 | 
				
			||||||
 | 
					+void mt2701_afe_disable_mclk(struct mtk_base_afe *afe, int id);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-int mt2701_turn_on_a2sys_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					-void mt2701_turn_off_a2sys_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-int mt2701_turn_on_afe_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					-void mt2701_turn_off_afe_clock(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					+int mt2701_enable_btmrg_clk(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					+void mt2701_disable_btmrg_clk(struct mtk_base_afe *afe);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 void mt2701_mclk_configuration(struct mtk_base_afe *afe, int id, int domain,
 | 
				
			||||||
 | 
					 			       int mclk);
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-common.h b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					index c19430e98adf..ce5bd4dc864d 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					@@ -69,53 +69,14 @@ enum {
 | 
				
			||||||
 | 
					 	MT2701_IRQ_ASYS_END,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* 2701 clock def */
 | 
				
			||||||
 | 
					-enum audio_system_clock_type {
 | 
				
			||||||
 | 
					-	MT2701_AUD_INFRA_SYS_AUDIO,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_MUX1_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_MUX2_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_MUX1_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_MUX2_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_48K_TIMING,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_44K_TIMING,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL_MUX_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_APLL_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD1PLL_98M,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD2PLL_90M,
 | 
				
			||||||
 | 
					-	MT2701_AUD_HADDS2PLL_98M,
 | 
				
			||||||
 | 
					-	MT2701_AUD_HADDS2PLL_294M,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL_D4,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL_D8,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL_D16,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDPLL_D24,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUDINTBUS,
 | 
				
			||||||
 | 
					-	MT2701_AUD_CLK_26M,
 | 
				
			||||||
 | 
					-	MT2701_AUD_SYSPLL1_D4,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K1_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K2_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K3_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K4_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K5_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K6_SRC_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K1_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K2_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K3_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K4_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K5_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_K6_SRC_DIV,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S1_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S2_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S3_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S4_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S5_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_AUD_I2S6_MCLK,
 | 
				
			||||||
 | 
					-	MT2701_AUD_ASM_M_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_ASM_H_SEL,
 | 
				
			||||||
 | 
					-	MT2701_AUD_UNIVPLL2_D4,
 | 
				
			||||||
 | 
					-	MT2701_AUD_UNIVPLL2_D2,
 | 
				
			||||||
 | 
					-	MT2701_AUD_SYSPLL_D5,
 | 
				
			||||||
 | 
					-	MT2701_CLOCK_NUM
 | 
				
			||||||
 | 
					+enum audio_base_clock {
 | 
				
			||||||
 | 
					+	MT2701_TOP_AUD_MCLK_SRC0,
 | 
				
			||||||
 | 
					+	MT2701_TOP_AUD_MCLK_SRC1,
 | 
				
			||||||
 | 
					+	MT2701_AUDSYS_AFE,
 | 
				
			||||||
 | 
					+	MT2701_AUDSYS_AFE_CONN,
 | 
				
			||||||
 | 
					+	MT2701_AUDSYS_A1SYS,
 | 
				
			||||||
 | 
					+	MT2701_AUDSYS_A2SYS,
 | 
				
			||||||
 | 
					+	MT2701_BASE_CLK_NUM,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const unsigned int mt2701_afe_backup_list[] = {
 | 
				
			||||||
 | 
					@@ -144,7 +105,6 @@ struct mtk_base_irq_data;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 struct mt2701_i2s_data {
 | 
				
			||||||
 | 
					 	int i2s_ctrl_reg;
 | 
				
			||||||
 | 
					-	int i2s_pwn_shift;
 | 
				
			||||||
 | 
					 	int i2s_asrc_fs_shift;
 | 
				
			||||||
 | 
					 	int i2s_asrc_fs_mask;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					@@ -161,11 +121,17 @@ struct mt2701_i2s_path {
 | 
				
			||||||
 | 
					 	int on[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					 	int occupied[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					 	const struct mt2701_i2s_data *i2s_data[2];
 | 
				
			||||||
 | 
					+	struct clk *hop_ck[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					+	struct clk *sel_ck;
 | 
				
			||||||
 | 
					+	struct clk *div_ck;
 | 
				
			||||||
 | 
					+	struct clk *mclk_ck;
 | 
				
			||||||
 | 
					+	struct clk *asrco_ck;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 struct mt2701_afe_private {
 | 
				
			||||||
 | 
					-	struct clk *clocks[MT2701_CLOCK_NUM];
 | 
				
			||||||
 | 
					 	struct mt2701_i2s_path i2s_path[MT2701_I2S_NUM];
 | 
				
			||||||
 | 
					+	struct clk *base_ck[MT2701_BASE_CLK_NUM];
 | 
				
			||||||
 | 
					+	struct clk *mrgif_ck;
 | 
				
			||||||
 | 
					 	bool mrg_enable[MT2701_STREAM_DIR_NUM];
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					index a7362d1cda1b..33f809228f25 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					@@ -97,21 +97,12 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);
 | 
				
			||||||
 | 
					-	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 	int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
 | 
				
			||||||
 | 
					-	int clk_num = MT2701_AUD_AUD_I2S1_MCLK + i2s_num;
 | 
				
			||||||
 | 
					-	int ret = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	if (i2s_num < 0)
 | 
				
			||||||
 | 
					 		return i2s_num;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/* enable mclk */
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->clocks[clk_num]);
 | 
				
			||||||
 | 
					-	if (ret)
 | 
				
			||||||
 | 
					-		dev_err(afe->dev, "Failed to enable mclk for I2S: %d\n",
 | 
				
			||||||
 | 
					-			i2s_num);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	return ret;
 | 
				
			||||||
 | 
					+	return mt2701_afe_enable_mclk(afe, i2s_num);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					@@ -151,9 +142,9 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 	/* disable i2s */
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg,
 | 
				
			||||||
 | 
					 			   ASYS_I2S_CON_I2S_EN, 0);
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   1 << i2s_data->i2s_pwn_shift,
 | 
				
			||||||
 | 
					-			   1 << i2s_data->i2s_pwn_shift);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	mt2701_afe_disable_i2s(afe, i2s_num, stream_dir);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -165,7 +156,6 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 	int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
 | 
				
			||||||
 | 
					 	struct mt2701_i2s_path *i2s_path;
 | 
				
			||||||
 | 
					-	int clk_num = MT2701_AUD_AUD_I2S1_MCLK + i2s_num;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	if (i2s_num < 0)
 | 
				
			||||||
 | 
					 		return;
 | 
				
			||||||
 | 
					@@ -185,7 +175,7 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 I2S_UNSTART:
 | 
				
			||||||
 | 
					 	/* disable mclk */
 | 
				
			||||||
 | 
					-	clk_disable_unprepare(afe_priv->clocks[clk_num]);
 | 
				
			||||||
 | 
					+	mt2701_afe_disable_mclk(afe, i2s_num);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					@@ -251,9 +241,7 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 			   fs << i2s_data->i2s_asrc_fs_shift);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* enable i2s */
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   1 << i2s_data->i2s_pwn_shift,
 | 
				
			||||||
 | 
					-			   0 << i2s_data->i2s_pwn_shift);
 | 
				
			||||||
 | 
					+	mt2701_afe_enable_i2s(afe, i2s_num, stream_dir);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* reset i2s hw status before enable */
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, i2s_data->i2s_ctrl_reg,
 | 
				
			||||||
 | 
					@@ -339,9 +327,11 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					+	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON4_PDN_MRGIF, 0);
 | 
				
			||||||
 | 
					+	ret = mt2701_enable_btmrg_clk(afe);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	afe_priv->mrg_enable[substream->stream] = 1;
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					@@ -406,9 +396,7 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 				   AFE_MRGIF_CON_MRG_EN, 0);
 | 
				
			||||||
 | 
					 		regmap_update_bits(afe->regmap, AFE_MRGIF_CON,
 | 
				
			||||||
 | 
					 				   AFE_MRGIF_CON_MRG_I2S_EN, 0);
 | 
				
			||||||
 | 
					-		regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
 | 
				
			||||||
 | 
					-				   AUDIO_TOP_CON4_PDN_MRGIF,
 | 
				
			||||||
 | 
					-				   AUDIO_TOP_CON4_PDN_MRGIF);
 | 
				
			||||||
 | 
					+		mt2701_disable_btmrg_clk(afe);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 	afe_priv->mrg_enable[substream->stream] = 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -1386,14 +1374,12 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SO1_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 6,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 0,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		},
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SIN1_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 0,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 0,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1402,14 +1388,12 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SO2_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 7,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 5,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		},
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SIN2_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 1,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 5,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1418,14 +1402,12 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SO3_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 8,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 10,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		},
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SIN3_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 2,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 10,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1434,14 +1416,12 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
 | 
				
			||||||
 | 
					 	{
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SO4_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 9,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 15,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 		},
 | 
				
			||||||
 | 
					 		{
 | 
				
			||||||
 | 
					 			.i2s_ctrl_reg = ASYS_I2SIN4_CON,
 | 
				
			||||||
 | 
					-			.i2s_pwn_shift = 3,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_shift = 15,
 | 
				
			||||||
 | 
					 			.i2s_asrc_fs_mask = 0x1f,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1483,8 +1463,7 @@ static int mt2701_afe_runtime_suspend(struct device *dev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe = dev_get_drvdata(dev);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	mt2701_afe_disable_clock(afe);
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					+	return mt2701_afe_disable_clock(afe);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_afe_runtime_resume(struct device *dev)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,439 @@
 | 
				
			|||||||
 | 
					From 4087c924ec899881951b2170a7bb8888747ec532 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Tue, 2 Jan 2018 19:47:20 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 182/224] ASoC: mediatek: cleanup audio driver for MT2701
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Cleanup unused code such as 'i2s_num' guard, headers, indentation
 | 
				
			||||||
 | 
					and some defines.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c | 14 +---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-common.h     | 20 +----
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c        | 94 ++++-------------------
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-reg.h            | 41 +---------
 | 
				
			||||||
 | 
					 4 files changed, 24 insertions(+), 145 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					index 75ccdca5811d..56a057c78c9a 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					@@ -14,10 +14,6 @@
 | 
				
			||||||
 | 
					  * GNU General Public License for more details.
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#include <sound/soc.h>
 | 
				
			||||||
 | 
					-#include <linux/regmap.h>
 | 
				
			||||||
 | 
					-#include <linux/pm_runtime.h>
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 #include "mt2701-afe-common.h"
 | 
				
			||||||
 | 
					 #include "mt2701-afe-clock-ctrl.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -223,8 +219,8 @@ int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON);
 | 
				
			||||||
 | 
					+			   ASYS_TOP_CON_ASYS_TIMING_ON,
 | 
				
			||||||
 | 
					+			   ASYS_TOP_CON_ASYS_TIMING_ON);
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					 			   AFE_DAC_CON0_AFE_ON,
 | 
				
			||||||
 | 
					 			   AFE_DAC_CON0_AFE_ON);
 | 
				
			||||||
 | 
					@@ -239,7 +235,7 @@ int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 int mt2701_afe_disable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, ASYS_TOP_CON,
 | 
				
			||||||
 | 
					-			   AUDIO_TOP_CON0_A1SYS_A2SYS_ON, 0);
 | 
				
			||||||
 | 
					+			   ASYS_TOP_CON_ASYS_TIMING_ON, 0);
 | 
				
			||||||
 | 
					 	regmap_update_bits(afe->regmap, AFE_DAC_CON0,
 | 
				
			||||||
 | 
					 			   AFE_DAC_CON0_AFE_ON, 0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -272,7 +268,3 @@ void mt2701_mclk_configuration(struct mtk_base_afe *afe, int id, int domain,
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					 		dev_err(afe->dev, "failed to set mclk divider %d\n", ret);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-MODULE_DESCRIPTION("MT2701 afe clock control");
 | 
				
			||||||
 | 
					-MODULE_AUTHOR("Garlic Tseng <garlic.tseng@mediatek.com>");
 | 
				
			||||||
 | 
					-MODULE_LICENSE("GPL v2");
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-common.h b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					index ce5bd4dc864d..9a2b301a4c21 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					@@ -16,6 +16,7 @@
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #ifndef _MT_2701_AFE_COMMON_H_
 | 
				
			||||||
 | 
					 #define _MT_2701_AFE_COMMON_H_
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 #include <sound/soc.h>
 | 
				
			||||||
 | 
					 #include <linux/clk.h>
 | 
				
			||||||
 | 
					 #include <linux/regmap.h>
 | 
				
			||||||
 | 
					@@ -25,16 +26,7 @@
 | 
				
			||||||
 | 
					 #define MT2701_STREAM_DIR_NUM (SNDRV_PCM_STREAM_LAST + 1)
 | 
				
			||||||
 | 
					 #define MT2701_PLL_DOMAIN_0_RATE	98304000
 | 
				
			||||||
 | 
					 #define MT2701_PLL_DOMAIN_1_RATE	90316800
 | 
				
			||||||
 | 
					-#define MT2701_AUD_AUD_MUX1_DIV_RATE (MT2701_PLL_DOMAIN_0_RATE / 2)
 | 
				
			||||||
 | 
					-#define MT2701_AUD_AUD_MUX2_DIV_RATE (MT2701_PLL_DOMAIN_1_RATE / 2)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-enum {
 | 
				
			||||||
 | 
					-	MT2701_I2S_1,
 | 
				
			||||||
 | 
					-	MT2701_I2S_2,
 | 
				
			||||||
 | 
					-	MT2701_I2S_3,
 | 
				
			||||||
 | 
					-	MT2701_I2S_4,
 | 
				
			||||||
 | 
					-	MT2701_I2S_NUM,
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					+#define MT2701_I2S_NUM	4
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 enum {
 | 
				
			||||||
 | 
					 	MT2701_MEMIF_DL1,
 | 
				
			||||||
 | 
					@@ -62,8 +54,7 @@ enum {
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 enum {
 | 
				
			||||||
 | 
					-	MT2701_IRQ_ASYS_START,
 | 
				
			||||||
 | 
					-	MT2701_IRQ_ASYS_IRQ1 = MT2701_IRQ_ASYS_START,
 | 
				
			||||||
 | 
					+	MT2701_IRQ_ASYS_IRQ1,
 | 
				
			||||||
 | 
					 	MT2701_IRQ_ASYS_IRQ2,
 | 
				
			||||||
 | 
					 	MT2701_IRQ_ASYS_IRQ3,
 | 
				
			||||||
 | 
					 	MT2701_IRQ_ASYS_END,
 | 
				
			||||||
 | 
					@@ -100,9 +91,6 @@ static const unsigned int mt2701_afe_backup_list[] = {
 | 
				
			||||||
 | 
					 	AFE_MEMIF_PBUF_SIZE,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-struct snd_pcm_substream;
 | 
				
			||||||
 | 
					-struct mtk_base_irq_data;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 struct mt2701_i2s_data {
 | 
				
			||||||
 | 
					 	int i2s_ctrl_reg;
 | 
				
			||||||
 | 
					 	int i2s_asrc_fs_shift;
 | 
				
			||||||
 | 
					@@ -120,7 +108,7 @@ struct mt2701_i2s_path {
 | 
				
			||||||
 | 
					 	int mclk_rate;
 | 
				
			||||||
 | 
					 	int on[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					 	int occupied[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					-	const struct mt2701_i2s_data *i2s_data[2];
 | 
				
			||||||
 | 
					+	const struct mt2701_i2s_data *i2s_data[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					 	struct clk *hop_ck[I2S_DIR_NUM];
 | 
				
			||||||
 | 
					 	struct clk *sel_ck;
 | 
				
			||||||
 | 
					 	struct clk *div_ck;
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					index 33f809228f25..0edadca12a5e 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					@@ -20,16 +20,12 @@
 | 
				
			||||||
 | 
					 #include <linux/of.h>
 | 
				
			||||||
 | 
					 #include <linux/of_address.h>
 | 
				
			||||||
 | 
					 #include <linux/pm_runtime.h>
 | 
				
			||||||
 | 
					-#include <sound/soc.h>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #include "mt2701-afe-common.h"
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 #include "mt2701-afe-clock-ctrl.h"
 | 
				
			||||||
 | 
					 #include "../common/mtk-afe-platform-driver.h"
 | 
				
			||||||
 | 
					 #include "../common/mtk-afe-fe-dai.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#define AFE_IRQ_STATUS_BITS	0xff
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 static const struct snd_pcm_hardware mt2701_afe_hardware = {
 | 
				
			||||||
 | 
					 	.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED
 | 
				
			||||||
 | 
					 		| SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID,
 | 
				
			||||||
 | 
					@@ -107,21 +103,16 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 					struct snd_soc_dai *dai,
 | 
				
			||||||
 | 
					+					int i2s_num,
 | 
				
			||||||
 | 
					 					int dir_invert)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					-	int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
 | 
				
			||||||
 | 
					-	struct mt2701_i2s_path *i2s_path;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num];
 | 
				
			||||||
 | 
					 	const struct mt2701_i2s_data *i2s_data;
 | 
				
			||||||
 | 
					 	int stream_dir = substream->stream;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	if (i2s_num < 0)
 | 
				
			||||||
 | 
					-		return i2s_num;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	i2s_path = &afe_priv->i2s_path[i2s_num];
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	if (dir_invert)	{
 | 
				
			||||||
 | 
					 		if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK)
 | 
				
			||||||
 | 
					 			stream_dir = SNDRV_PCM_STREAM_CAPTURE;
 | 
				
			||||||
 | 
					@@ -167,11 +158,11 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 	else
 | 
				
			||||||
 | 
					 		goto I2S_UNSTART;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	mt2701_afe_i2s_path_shutdown(substream, dai, 0);
 | 
				
			||||||
 | 
					+	mt2701_afe_i2s_path_shutdown(substream, dai, i2s_num, 0);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* need to disable i2s-out path when disable i2s-in */
 | 
				
			||||||
 | 
					 	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
 | 
				
			||||||
 | 
					-		mt2701_afe_i2s_path_shutdown(substream, dai, 1);
 | 
				
			||||||
 | 
					+		mt2701_afe_i2s_path_shutdown(substream, dai, i2s_num, 1);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 I2S_UNSTART:
 | 
				
			||||||
 | 
					 	/* disable mclk */
 | 
				
			||||||
 | 
					@@ -180,24 +171,19 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 					  struct snd_soc_dai *dai,
 | 
				
			||||||
 | 
					+					  int i2s_num,
 | 
				
			||||||
 | 
					 					  int dir_invert)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					-	int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
 | 
				
			||||||
 | 
					-	struct mt2701_i2s_path *i2s_path;
 | 
				
			||||||
 | 
					+	struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num];
 | 
				
			||||||
 | 
					 	const struct mt2701_i2s_data *i2s_data;
 | 
				
			||||||
 | 
					 	struct snd_pcm_runtime * const runtime = substream->runtime;
 | 
				
			||||||
 | 
					 	int reg, fs, w_len = 1; /* now we support bck 64bits only */
 | 
				
			||||||
 | 
					 	int stream_dir = substream->stream;
 | 
				
			||||||
 | 
					 	unsigned int mask = 0, val = 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	if (i2s_num < 0)
 | 
				
			||||||
 | 
					-		return i2s_num;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	i2s_path = &afe_priv->i2s_path[i2s_num];
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	if (dir_invert) {
 | 
				
			||||||
 | 
					 		if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK)
 | 
				
			||||||
 | 
					 			stream_dir = SNDRV_PCM_STREAM_CAPTURE;
 | 
				
			||||||
 | 
					@@ -288,13 +274,13 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream,
 | 
				
			||||||
 | 
					 	mt2701_mclk_configuration(afe, i2s_num, clk_domain, mclk_rate);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
 | 
					-		mt2701_i2s_path_prepare_enable(substream, dai, 0);
 | 
				
			||||||
 | 
					+		mt2701_i2s_path_prepare_enable(substream, dai, i2s_num, 0);
 | 
				
			||||||
 | 
					 	} else {
 | 
				
			||||||
 | 
					 		/* need to enable i2s-out path when enable i2s-in */
 | 
				
			||||||
 | 
					 		/* prepare for another direction "out" */
 | 
				
			||||||
 | 
					-		mt2701_i2s_path_prepare_enable(substream, dai, 1);
 | 
				
			||||||
 | 
					+		mt2701_i2s_path_prepare_enable(substream, dai, i2s_num, 1);
 | 
				
			||||||
 | 
					 		/* prepare for "in" */
 | 
				
			||||||
 | 
					-		mt2701_i2s_path_prepare_enable(substream, dai, 0);
 | 
				
			||||||
 | 
					+		mt2701_i2s_path_prepare_enable(substream, dai, i2s_num, 0);
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					@@ -562,7 +548,6 @@ static const struct snd_soc_dai_ops mt2701_single_memif_dai_ops = {
 | 
				
			||||||
 | 
					 	.hw_free	= mtk_afe_fe_hw_free,
 | 
				
			||||||
 | 
					 	.prepare	= mtk_afe_fe_prepare,
 | 
				
			||||||
 | 
					 	.trigger	= mtk_afe_fe_trigger,
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct snd_soc_dai_ops mt2701_dlm_memif_dai_ops = {
 | 
				
			||||||
 | 
					@@ -903,31 +888,6 @@ static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_i2s4[] = {
 | 
				
			||||||
 | 
					 				    PWR2_TOP_CON, 19, 1, 0),
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc0[] = {
 | 
				
			||||||
 | 
					-	SOC_DAPM_SINGLE_AUTODISABLE("Asrc0 out Switch", AUDIO_TOP_CON4, 14, 1,
 | 
				
			||||||
 | 
					-				    1),
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc1[] = {
 | 
				
			||||||
 | 
					-	SOC_DAPM_SINGLE_AUTODISABLE("Asrc1 out Switch", AUDIO_TOP_CON4, 15, 1,
 | 
				
			||||||
 | 
					-				    1),
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc2[] = {
 | 
				
			||||||
 | 
					-	SOC_DAPM_SINGLE_AUTODISABLE("Asrc2 out Switch", PWR2_TOP_CON, 6, 1,
 | 
				
			||||||
 | 
					-				    1),
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc3[] = {
 | 
				
			||||||
 | 
					-	SOC_DAPM_SINGLE_AUTODISABLE("Asrc3 out Switch", PWR2_TOP_CON, 7, 1,
 | 
				
			||||||
 | 
					-				    1),
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc4[] = {
 | 
				
			||||||
 | 
					-	SOC_DAPM_SINGLE_AUTODISABLE("Asrc4 out Switch", PWR2_TOP_CON, 8, 1,
 | 
				
			||||||
 | 
					-				    1),
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 static const struct snd_soc_dapm_widget mt2701_afe_pcm_widgets[] = {
 | 
				
			||||||
 | 
					 	/* inter-connections */
 | 
				
			||||||
 | 
					 	SND_SOC_DAPM_MIXER("I00", SND_SOC_NOPM, 0, 0, NULL, 0),
 | 
				
			||||||
 | 
					@@ -987,19 +947,6 @@ static const struct snd_soc_dapm_widget mt2701_afe_pcm_widgets[] = {
 | 
				
			||||||
 | 
					 	SND_SOC_DAPM_MIXER("I18I19", SND_SOC_NOPM, 0, 0,
 | 
				
			||||||
 | 
					 			   mt2701_afe_multi_ch_out_i2s3,
 | 
				
			||||||
 | 
					 			   ARRAY_SIZE(mt2701_afe_multi_ch_out_i2s3)),
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	SND_SOC_DAPM_MIXER("ASRC_O0", SND_SOC_NOPM, 0, 0,
 | 
				
			||||||
 | 
					-			   mt2701_afe_multi_ch_out_asrc0,
 | 
				
			||||||
 | 
					-			   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc0)),
 | 
				
			||||||
 | 
					-	SND_SOC_DAPM_MIXER("ASRC_O1", SND_SOC_NOPM, 0, 0,
 | 
				
			||||||
 | 
					-			   mt2701_afe_multi_ch_out_asrc1,
 | 
				
			||||||
 | 
					-			   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc1)),
 | 
				
			||||||
 | 
					-	SND_SOC_DAPM_MIXER("ASRC_O2", SND_SOC_NOPM, 0, 0,
 | 
				
			||||||
 | 
					-			   mt2701_afe_multi_ch_out_asrc2,
 | 
				
			||||||
 | 
					-			   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc2)),
 | 
				
			||||||
 | 
					-	SND_SOC_DAPM_MIXER("ASRC_O3", SND_SOC_NOPM, 0, 0,
 | 
				
			||||||
 | 
					-			   mt2701_afe_multi_ch_out_asrc3,
 | 
				
			||||||
 | 
					-			   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc3)),
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
 | 
				
			||||||
 | 
					@@ -1009,7 +956,6 @@ static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	{"I2S0 Playback", NULL, "O15"},
 | 
				
			||||||
 | 
					 	{"I2S0 Playback", NULL, "O16"},
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	{"I2S1 Playback", NULL, "O17"},
 | 
				
			||||||
 | 
					 	{"I2S1 Playback", NULL, "O18"},
 | 
				
			||||||
 | 
					 	{"I2S2 Playback", NULL, "O19"},
 | 
				
			||||||
 | 
					@@ -1026,7 +972,6 @@ static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	{"I00", NULL, "I2S0 Capture"},
 | 
				
			||||||
 | 
					 	{"I01", NULL, "I2S0 Capture"},
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	{"I02", NULL, "I2S1 Capture"},
 | 
				
			||||||
 | 
					 	{"I03", NULL, "I2S1 Capture"},
 | 
				
			||||||
 | 
					 	/* I02,03 link to UL2, also need to open I2S0 */
 | 
				
			||||||
 | 
					@@ -1034,15 +979,10 @@ static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	{"I26", NULL, "BT Capture"},
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	{"ASRC_O0", "Asrc0 out Switch", "DLM"},
 | 
				
			||||||
 | 
					-	{"ASRC_O1", "Asrc1 out Switch", "DLM"},
 | 
				
			||||||
 | 
					-	{"ASRC_O2", "Asrc2 out Switch", "DLM"},
 | 
				
			||||||
 | 
					-	{"ASRC_O3", "Asrc3 out Switch", "DLM"},
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	{"I12I13", "Multich I2S0 Out Switch", "ASRC_O0"},
 | 
				
			||||||
 | 
					-	{"I14I15", "Multich I2S1 Out Switch", "ASRC_O1"},
 | 
				
			||||||
 | 
					-	{"I16I17", "Multich I2S2 Out Switch", "ASRC_O2"},
 | 
				
			||||||
 | 
					-	{"I18I19", "Multich I2S3 Out Switch", "ASRC_O3"},
 | 
				
			||||||
 | 
					+	{"I12I13", "Multich I2S0 Out Switch", "DLM"},
 | 
				
			||||||
 | 
					+	{"I14I15", "Multich I2S1 Out Switch", "DLM"},
 | 
				
			||||||
 | 
					+	{"I16I17", "Multich I2S2 Out Switch", "DLM"},
 | 
				
			||||||
 | 
					+	{"I18I19", "Multich I2S3 Out Switch", "DLM"},
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	{ "I12", NULL, "I12I13" },
 | 
				
			||||||
 | 
					 	{ "I13", NULL, "I12I13" },
 | 
				
			||||||
 | 
					@@ -1067,7 +1007,6 @@ static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
 | 
				
			||||||
 | 
					 	{ "O21", "I18 Switch", "I18" },
 | 
				
			||||||
 | 
					 	{ "O22", "I19 Switch", "I19" },
 | 
				
			||||||
 | 
					 	{ "O31", "I35 Switch", "I35" },
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const struct snd_soc_component_driver mt2701_afe_pcm_dai_component = {
 | 
				
			||||||
 | 
					@@ -1484,12 +1423,13 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
 | 
				
			||||||
 | 
					 	if (!afe)
 | 
				
			||||||
 | 
					 		return -ENOMEM;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
 | 
				
			||||||
 | 
					 					  GFP_KERNEL);
 | 
				
			||||||
 | 
					 	if (!afe->platform_priv)
 | 
				
			||||||
 | 
					 		return -ENOMEM;
 | 
				
			||||||
 | 
					-	afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 	afe->dev = &pdev->dev;
 | 
				
			||||||
 | 
					 	dev = afe->dev;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1524,7 +1464,6 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	afe->memif_size = MT2701_MEMIF_NUM;
 | 
				
			||||||
 | 
					 	afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif),
 | 
				
			||||||
 | 
					 				  GFP_KERNEL);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	if (!afe->memif)
 | 
				
			||||||
 | 
					 		return -ENOMEM;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1537,7 +1476,6 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	afe->irqs_size = MT2701_IRQ_ASYS_END;
 | 
				
			||||||
 | 
					 	afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs),
 | 
				
			||||||
 | 
					 				 GFP_KERNEL);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	if (!afe->irqs)
 | 
				
			||||||
 | 
					 		return -ENOMEM;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1555,7 +1493,6 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	afe->mtk_afe_hardware = &mt2701_afe_hardware;
 | 
				
			||||||
 | 
					 	afe->memif_fs = mt2701_memif_fs;
 | 
				
			||||||
 | 
					 	afe->irq_fs = mt2701_irq_fs;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 	afe->reg_back_up_list = mt2701_afe_backup_list;
 | 
				
			||||||
 | 
					 	afe->reg_back_up_list_num = ARRAY_SIZE(mt2701_afe_backup_list);
 | 
				
			||||||
 | 
					 	afe->runtime_resume = mt2701_afe_runtime_resume;
 | 
				
			||||||
 | 
					@@ -1646,4 +1583,3 @@ module_platform_driver(mt2701_afe_pcm_driver);
 | 
				
			||||||
 | 
					 MODULE_DESCRIPTION("Mediatek ALSA SoC AFE platform driver for 2701");
 | 
				
			||||||
 | 
					 MODULE_AUTHOR("Garlic Tseng <garlic.tseng@mediatek.com>");
 | 
				
			||||||
 | 
					 MODULE_LICENSE("GPL v2");
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-reg.h b/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					index bb62b1c55957..f17c76f37b5f 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					@@ -17,17 +17,6 @@
 | 
				
			||||||
 | 
					 #ifndef _MT2701_REG_H_
 | 
				
			||||||
 | 
					 #define _MT2701_REG_H_
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#include <linux/delay.h>
 | 
				
			||||||
 | 
					-#include <linux/module.h>
 | 
				
			||||||
 | 
					-#include <linux/of.h>
 | 
				
			||||||
 | 
					-#include <linux/of_address.h>
 | 
				
			||||||
 | 
					-#include <linux/pm_runtime.h>
 | 
				
			||||||
 | 
					-#include <sound/soc.h>
 | 
				
			||||||
 | 
					-#include "mt2701-afe-common.h"
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/*****************************************************************************
 | 
				
			||||||
 | 
					- *                  R E G I S T E R       D E F I N I T I O N
 | 
				
			||||||
 | 
					- *****************************************************************************/
 | 
				
			||||||
 | 
					 #define AUDIO_TOP_CON0 0x0000
 | 
				
			||||||
 | 
					 #define AUDIO_TOP_CON4 0x0010
 | 
				
			||||||
 | 
					 #define AUDIO_TOP_CON5 0x0014
 | 
				
			||||||
 | 
					@@ -109,18 +98,6 @@
 | 
				
			||||||
 | 
					 #define AFE_DAI_BASE 0x1370
 | 
				
			||||||
 | 
					 #define AFE_DAI_CUR 0x137c
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* AUDIO_TOP_CON0 (0x0000) */
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON0_A1SYS_A2SYS_ON	(0x3 << 0)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON0_PDN_AFE		(0x1 << 2)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON0_PDN_APLL_CK	(0x1 << 23)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* AUDIO_TOP_CON4 (0x0010) */
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON4_I2SO1_PWN	(0x1 << 6)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON4_PDN_A1SYS	(0x1 << 21)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON4_PDN_A2SYS	(0x1 << 22)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON4_PDN_AFE_CONN	(0x1 << 23)
 | 
				
			||||||
 | 
					-#define AUDIO_TOP_CON4_PDN_MRGIF	(0x1 << 25)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 /* AFE_DAIBT_CON0 (0x001c) */
 | 
				
			||||||
 | 
					 #define AFE_DAIBT_CON0_DAIBT_EN		(0x1 << 0)
 | 
				
			||||||
 | 
					 #define AFE_DAIBT_CON0_BT_FUNC_EN	(0x1 << 1)
 | 
				
			||||||
 | 
					@@ -137,22 +114,8 @@
 | 
				
			||||||
 | 
					 #define AFE_MRGIF_CON_I2S_MODE_MASK	(0xf << 20)
 | 
				
			||||||
 | 
					 #define AFE_MRGIF_CON_I2S_MODE_32K	(0x4 << 20)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/* ASYS_I2SO1_CON (0x061c) */
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_FS		(0x1f << 8)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_FS_SET(x)	((x) << 8)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_MULTI_CH		(0x1 << 16)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_SIDEGEN		(0x1 << 30)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_I2S_EN		(0x1 << 0)
 | 
				
			||||||
 | 
					-/* 0:EIAJ 1:I2S */
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_I2S_MODE		(0x1 << 3)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_WIDE_MODE	(0x1 << 1)
 | 
				
			||||||
 | 
					-#define ASYS_I2SO1_CON_WIDE_MODE_SET(x)	((x) << 1)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* PWR2_TOP_CON (0x0634) */
 | 
				
			||||||
 | 
					-#define PWR2_TOP_CON_INIT_VAL		(0xffe1ffff)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-/* ASYS_IRQ_CLR (0x07c0) */
 | 
				
			||||||
 | 
					-#define ASYS_IRQ_CLR_ALL		(0xffffffff)
 | 
				
			||||||
 | 
					+/* ASYS_TOP_CON (0x0600) */
 | 
				
			||||||
 | 
					+#define ASYS_TOP_CON_ASYS_TIMING_ON		(0x3 << 0)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* PWR2_ASM_CON1 (0x1070) */
 | 
				
			||||||
 | 
					 #define PWR2_ASM_CON1_INIT_VAL		(0x492492)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,263 @@
 | 
				
			|||||||
 | 
					From d5b391bb7208c8a7b6b874c1357d3cd110537167 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Tue, 2 Jan 2018 19:47:21 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 183/224] ASoC: mediatek: update clock related properties of
 | 
				
			||||||
 | 
					 MT2701 AFE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Add 'assigned-clocks*' properties which are used to initialize default
 | 
				
			||||||
 | 
					domain sources of audio system. we could configure different sets of
 | 
				
			||||||
 | 
					input clocks through DTS now. Hence driver no longer cares about that.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Also we change some 'clock-names' to make them more generic so that
 | 
				
			||||||
 | 
					other chips can reuse gracefully.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 .../devicetree/bindings/sound/mt2701-afe-pcm.txt   | 207 +++++++++------------
 | 
				
			||||||
 | 
					 1 file changed, 91 insertions(+), 116 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					index 77a57f84bed4..0450baad2813 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					@@ -6,51 +6,44 @@ Required properties:
 | 
				
			||||||
 | 
					 - interrupts: should contain AFE and ASYS interrupts
 | 
				
			||||||
 | 
					 - interrupt-names: should be "afe" and "asys"
 | 
				
			||||||
 | 
					 - power-domains: should define the power domain
 | 
				
			||||||
 | 
					+- clocks: Must contain an entry for each entry in clock-names
 | 
				
			||||||
 | 
					+  See ../clocks/clock-bindings.txt for details
 | 
				
			||||||
 | 
					 - clock-names: should have these clock names:
 | 
				
			||||||
 | 
					-		"infra_sys_audio_clk",
 | 
				
			||||||
 | 
					 		"top_audio_mux1_sel",
 | 
				
			||||||
 | 
					 		"top_audio_mux2_sel",
 | 
				
			||||||
 | 
					-		"top_audio_mux1_div",
 | 
				
			||||||
 | 
					-		"top_audio_mux2_div",
 | 
				
			||||||
 | 
					-		"top_audio_48k_timing",
 | 
				
			||||||
 | 
					-		"top_audio_44k_timing",
 | 
				
			||||||
 | 
					-		"top_audpll_mux_sel",
 | 
				
			||||||
 | 
					-		"top_apll_sel",
 | 
				
			||||||
 | 
					-		"top_aud1_pll_98M",
 | 
				
			||||||
 | 
					-		"top_aud2_pll_90M",
 | 
				
			||||||
 | 
					-		"top_hadds2_pll_98M",
 | 
				
			||||||
 | 
					-		"top_hadds2_pll_294M",
 | 
				
			||||||
 | 
					-		"top_audpll",
 | 
				
			||||||
 | 
					-		"top_audpll_d4",
 | 
				
			||||||
 | 
					-		"top_audpll_d8",
 | 
				
			||||||
 | 
					-		"top_audpll_d16",
 | 
				
			||||||
 | 
					-		"top_audpll_d24",
 | 
				
			||||||
 | 
					-		"top_audintbus_sel",
 | 
				
			||||||
 | 
					-		"clk_26m",
 | 
				
			||||||
 | 
					-		"top_syspll1_d4",
 | 
				
			||||||
 | 
					-		"top_aud_k1_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k2_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k3_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k4_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k5_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k6_src_sel",
 | 
				
			||||||
 | 
					-		"top_aud_k1_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_k2_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_k3_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_k4_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_k5_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_k6_src_div",
 | 
				
			||||||
 | 
					-		"top_aud_i2s1_mclk",
 | 
				
			||||||
 | 
					-		"top_aud_i2s2_mclk",
 | 
				
			||||||
 | 
					-		"top_aud_i2s3_mclk",
 | 
				
			||||||
 | 
					-		"top_aud_i2s4_mclk",
 | 
				
			||||||
 | 
					-		"top_aud_i2s5_mclk",
 | 
				
			||||||
 | 
					-		"top_aud_i2s6_mclk",
 | 
				
			||||||
 | 
					-		"top_asm_m_sel",
 | 
				
			||||||
 | 
					-		"top_asm_h_sel",
 | 
				
			||||||
 | 
					-		"top_univpll2_d4",
 | 
				
			||||||
 | 
					-		"top_univpll2_d2",
 | 
				
			||||||
 | 
					-		"top_syspll_d5";
 | 
				
			||||||
 | 
					+		"i2s0_src_sel",
 | 
				
			||||||
 | 
					+		"i2s1_src_sel",
 | 
				
			||||||
 | 
					+		"i2s2_src_sel",
 | 
				
			||||||
 | 
					+		"i2s3_src_sel",
 | 
				
			||||||
 | 
					+		"i2s0_src_div",
 | 
				
			||||||
 | 
					+		"i2s1_src_div",
 | 
				
			||||||
 | 
					+		"i2s2_src_div",
 | 
				
			||||||
 | 
					+		"i2s3_src_div",
 | 
				
			||||||
 | 
					+		"i2s0_mclk_en",
 | 
				
			||||||
 | 
					+		"i2s1_mclk_en",
 | 
				
			||||||
 | 
					+		"i2s2_mclk_en",
 | 
				
			||||||
 | 
					+		"i2s3_mclk_en",
 | 
				
			||||||
 | 
					+		"i2so0_hop_ck",
 | 
				
			||||||
 | 
					+		"i2so1_hop_ck",
 | 
				
			||||||
 | 
					+		"i2so2_hop_ck",
 | 
				
			||||||
 | 
					+		"i2so3_hop_ck",
 | 
				
			||||||
 | 
					+		"i2si0_hop_ck",
 | 
				
			||||||
 | 
					+		"i2si1_hop_ck",
 | 
				
			||||||
 | 
					+		"i2si2_hop_ck",
 | 
				
			||||||
 | 
					+		"i2si3_hop_ck",
 | 
				
			||||||
 | 
					+		"asrc0_out_ck",
 | 
				
			||||||
 | 
					+		"asrc1_out_ck",
 | 
				
			||||||
 | 
					+		"asrc2_out_ck",
 | 
				
			||||||
 | 
					+		"asrc3_out_ck",
 | 
				
			||||||
 | 
					+		"audio_afe_pd",
 | 
				
			||||||
 | 
					+		"audio_afe_conn_pd",
 | 
				
			||||||
 | 
					+		"audio_a1sys_pd",
 | 
				
			||||||
 | 
					+		"audio_a2sys_pd",
 | 
				
			||||||
 | 
					+		"audio_mrgif_pd";
 | 
				
			||||||
 | 
					+- assigned-clocks: list of input clocks and dividers for the audio system.
 | 
				
			||||||
 | 
					+		   See ../clocks/clock-bindings.txt for details.
 | 
				
			||||||
 | 
					+- assigned-clocks-parents: parent of input clocks of assigned clocks.
 | 
				
			||||||
 | 
					+- assigned-clock-rates: list of clock frequencies of assigned clocks.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Example:
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -62,93 +55,75 @@ Example:
 | 
				
			||||||
 | 
					 			     <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
 | 
				
			||||||
 | 
					 		interrupt-names	= "afe", "asys";
 | 
				
			||||||
 | 
					 		power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
 | 
				
			||||||
 | 
					-		clocks = <&infracfg CLK_INFRA_AUDIO>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					+		clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_MUX1_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_MUX2_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_48K_TIMING>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_44K_TIMING>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL_MUX_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_APLL_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD1PLL_98M>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD2PLL_90M>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_HADDS2PLL_98M>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_HADDS2PLL_294M>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL_D4>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL_D8>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL_D16>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDPLL_D24>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUDINTBUS_SEL>,
 | 
				
			||||||
 | 
					-			 <&clk26m>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_SYSPLL1_D4>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K5_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K6_SRC_SEL>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K5_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K6_SRC_DIV>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
 | 
				
			||||||
 | 
					 			 <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S5_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S6_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_ASM_M_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_ASM_H_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_UNIVPLL2_D4>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_UNIVPLL2_D2>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_SYSPLL_D5>;
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SO1>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SO2>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SO3>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SO4>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SIN1>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SIN2>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SIN3>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_I2SIN4>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_ASRCO1>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_ASRCO2>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_ASRCO3>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_ASRCO4>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_AFE>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_AFE_CONN>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_A1SYS>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_A2SYS>,
 | 
				
			||||||
 | 
					+			 <&audiosys CLK_AUD_AFE_MRGIF>;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		clock-names = "infra_sys_audio_clk",
 | 
				
			||||||
 | 
					-			      "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					+		clock-names = "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					 			      "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					-			      "top_audio_mux1_div",
 | 
				
			||||||
 | 
					-			      "top_audio_mux2_div",
 | 
				
			||||||
 | 
					-			      "top_audio_48k_timing",
 | 
				
			||||||
 | 
					-			      "top_audio_44k_timing",
 | 
				
			||||||
 | 
					-			      "top_audpll_mux_sel",
 | 
				
			||||||
 | 
					-			      "top_apll_sel",
 | 
				
			||||||
 | 
					-			      "top_aud1_pll_98M",
 | 
				
			||||||
 | 
					-			      "top_aud2_pll_90M",
 | 
				
			||||||
 | 
					-			      "top_hadds2_pll_98M",
 | 
				
			||||||
 | 
					-			      "top_hadds2_pll_294M",
 | 
				
			||||||
 | 
					-			      "top_audpll",
 | 
				
			||||||
 | 
					-			      "top_audpll_d4",
 | 
				
			||||||
 | 
					-			      "top_audpll_d8",
 | 
				
			||||||
 | 
					-			      "top_audpll_d16",
 | 
				
			||||||
 | 
					-			      "top_audpll_d24",
 | 
				
			||||||
 | 
					-			      "top_audintbus_sel",
 | 
				
			||||||
 | 
					-			      "clk_26m",
 | 
				
			||||||
 | 
					-			      "top_syspll1_d4",
 | 
				
			||||||
 | 
					-			      "top_aud_k1_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k2_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k3_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k4_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k5_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k6_src_sel",
 | 
				
			||||||
 | 
					-			      "top_aud_k1_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_k2_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_k3_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_k4_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_k5_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_k6_src_div",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s1_mclk",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s2_mclk",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s3_mclk",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s4_mclk",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s5_mclk",
 | 
				
			||||||
 | 
					-			      "top_aud_i2s6_mclk",
 | 
				
			||||||
 | 
					-			      "top_asm_m_sel",
 | 
				
			||||||
 | 
					-			      "top_asm_h_sel",
 | 
				
			||||||
 | 
					-			      "top_univpll2_d4",
 | 
				
			||||||
 | 
					-			      "top_univpll2_d2",
 | 
				
			||||||
 | 
					-			      "top_syspll_d5";
 | 
				
			||||||
 | 
					+			      "i2s0_src_sel",
 | 
				
			||||||
 | 
					+			      "i2s1_src_sel",
 | 
				
			||||||
 | 
					+			      "i2s2_src_sel",
 | 
				
			||||||
 | 
					+			      "i2s3_src_sel",
 | 
				
			||||||
 | 
					+			      "i2s0_src_div",
 | 
				
			||||||
 | 
					+			      "i2s1_src_div",
 | 
				
			||||||
 | 
					+			      "i2s2_src_div",
 | 
				
			||||||
 | 
					+			      "i2s3_src_div",
 | 
				
			||||||
 | 
					+			      "i2s0_mclk_en",
 | 
				
			||||||
 | 
					+			      "i2s1_mclk_en",
 | 
				
			||||||
 | 
					+			      "i2s2_mclk_en",
 | 
				
			||||||
 | 
					+			      "i2s3_mclk_en",
 | 
				
			||||||
 | 
					+			      "i2so0_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2so1_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2so2_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2so3_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2si0_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2si1_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2si2_hop_ck",
 | 
				
			||||||
 | 
					+			      "i2si3_hop_ck",
 | 
				
			||||||
 | 
					+			      "asrc0_out_ck",
 | 
				
			||||||
 | 
					+			      "asrc1_out_ck",
 | 
				
			||||||
 | 
					+			      "asrc2_out_ck",
 | 
				
			||||||
 | 
					+			      "asrc3_out_ck",
 | 
				
			||||||
 | 
					+			      "audio_afe_pd",
 | 
				
			||||||
 | 
					+			      "audio_afe_conn_pd",
 | 
				
			||||||
 | 
					+			      "audio_a1sys_pd",
 | 
				
			||||||
 | 
					+			      "audio_a2sys_pd",
 | 
				
			||||||
 | 
					+			      "audio_mrgif_pd";
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+		assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					+				  <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					+				  <&topckgen CLK_TOP_AUD_MUX1_DIV>,
 | 
				
			||||||
 | 
					+				  <&topckgen CLK_TOP_AUD_MUX2_DIV>;
 | 
				
			||||||
 | 
					+		assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
 | 
				
			||||||
 | 
					+					 <&topckgen CLK_TOP_AUD2PLL_90M>;
 | 
				
			||||||
 | 
					+		assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
 | 
				
			||||||
 | 
					 	};
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,100 @@
 | 
				
			|||||||
 | 
					From e0e3768b73daae674c69db1f71718894274b7bfc Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 4 Jan 2018 15:44:07 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 184/224] ASoC: mediatek: add some core clocks for MT2701 AFE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Add three core clocks for MT2701 AFE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c | 30 ++++++++++++++++++++++-
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-common.h     |  3 +++
 | 
				
			||||||
 | 
					 2 files changed, 32 insertions(+), 1 deletion(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					index 56a057c78c9a..949fc3a1d025 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c
 | 
				
			||||||
 | 
					@@ -18,8 +18,11 @@
 | 
				
			||||||
 | 
					 #include "mt2701-afe-clock-ctrl.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static const char *const base_clks[] = {
 | 
				
			||||||
 | 
					+	[MT2701_INFRA_SYS_AUDIO] = "infra_sys_audio_clk",
 | 
				
			||||||
 | 
					 	[MT2701_TOP_AUD_MCLK_SRC0] = "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					 	[MT2701_TOP_AUD_MCLK_SRC1] = "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					+	[MT2701_TOP_AUD_A1SYS] = "top_audio_a1sys_hp",
 | 
				
			||||||
 | 
					+	[MT2701_TOP_AUD_A2SYS] = "top_audio_a2sys_hp",
 | 
				
			||||||
 | 
					 	[MT2701_AUDSYS_AFE] = "audio_afe_pd",
 | 
				
			||||||
 | 
					 	[MT2701_AUDSYS_AFE_CONN] = "audio_afe_conn_pd",
 | 
				
			||||||
 | 
					 	[MT2701_AUDSYS_A1SYS] = "audio_a1sys_pd",
 | 
				
			||||||
 | 
					@@ -169,10 +172,26 @@ static int mt2701_afe_enable_audsys(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv = afe->platform_priv;
 | 
				
			||||||
 | 
					 	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					+	/* Enable infra clock gate */
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					 		return ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	/* Enable top a1sys clock gate */
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_TOP_AUD_A1SYS]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_a1sys;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	/* Enable top a2sys clock gate */
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_TOP_AUD_A2SYS]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_a2sys;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	/* Internal clock gates */
 | 
				
			||||||
 | 
					+	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		goto err_afe;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	ret = clk_prepare_enable(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					 		goto err_audio_a1sys;
 | 
				
			||||||
 | 
					@@ -193,6 +212,12 @@ static int mt2701_afe_enable_audsys(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					 err_audio_a1sys:
 | 
				
			||||||
 | 
					 	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					+err_afe:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_TOP_AUD_A2SYS]);
 | 
				
			||||||
 | 
					+err_a2sys:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_TOP_AUD_A1SYS]);
 | 
				
			||||||
 | 
					+err_a1sys:
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return ret;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -205,6 +230,9 @@ static void mt2701_afe_disable_audsys(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					 	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A2SYS]);
 | 
				
			||||||
 | 
					 	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_A1SYS]);
 | 
				
			||||||
 | 
					 	clk_disable_unprepare(afe_priv->base_ck[MT2701_AUDSYS_AFE]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_TOP_AUD_A1SYS]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_TOP_AUD_A2SYS]);
 | 
				
			||||||
 | 
					+	clk_disable_unprepare(afe_priv->base_ck[MT2701_INFRA_SYS_AUDIO]);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-common.h b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					index 9a2b301a4c21..ae8ddeacfbfe 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
 | 
				
			||||||
 | 
					@@ -61,8 +61,11 @@ enum {
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 enum audio_base_clock {
 | 
				
			||||||
 | 
					+	MT2701_INFRA_SYS_AUDIO,
 | 
				
			||||||
 | 
					 	MT2701_TOP_AUD_MCLK_SRC0,
 | 
				
			||||||
 | 
					 	MT2701_TOP_AUD_MCLK_SRC1,
 | 
				
			||||||
 | 
					+	MT2701_TOP_AUD_A1SYS,
 | 
				
			||||||
 | 
					+	MT2701_TOP_AUD_A2SYS,
 | 
				
			||||||
 | 
					 	MT2701_AUDSYS_AFE,
 | 
				
			||||||
 | 
					 	MT2701_AUDSYS_AFE_CONN,
 | 
				
			||||||
 | 
					 	MT2701_AUDSYS_A1SYS,
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					From 310ca2954c7cce10d716001ff869bc255494e3df Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 4 Jan 2018 15:44:08 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 185/224] ASoC: mediatek: modify MT2701 AFE driver to adapt mfd
 | 
				
			||||||
 | 
					 device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					As the new MFD parent is in place, modify MT2701 AFE driver to adapt it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 45 +++++++++++++-----------------
 | 
				
			||||||
 | 
					 sound/soc/mediatek/mt2701/mt2701-reg.h     |  1 -
 | 
				
			||||||
 | 
					 2 files changed, 20 insertions(+), 26 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					index 0edadca12a5e..f0cd08fa5c5d 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
 | 
				
			||||||
 | 
					@@ -17,6 +17,7 @@
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #include <linux/delay.h>
 | 
				
			||||||
 | 
					 #include <linux/module.h>
 | 
				
			||||||
 | 
					+#include <linux/mfd/syscon.h>
 | 
				
			||||||
 | 
					 #include <linux/of.h>
 | 
				
			||||||
 | 
					 #include <linux/of_address.h>
 | 
				
			||||||
 | 
					 #include <linux/pm_runtime.h>
 | 
				
			||||||
 | 
					@@ -1368,14 +1369,6 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
 | 
				
			||||||
 | 
					 	},
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static const struct regmap_config mt2701_afe_regmap_config = {
 | 
				
			||||||
 | 
					-	.reg_bits = 32,
 | 
				
			||||||
 | 
					-	.reg_stride = 4,
 | 
				
			||||||
 | 
					-	.val_bits = 32,
 | 
				
			||||||
 | 
					-	.max_register = AFE_END_ADDR,
 | 
				
			||||||
 | 
					-	.cache_type = REGCACHE_NONE,
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 static irqreturn_t mt2701_asys_isr(int irq_id, void *dev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	int id;
 | 
				
			||||||
 | 
					@@ -1414,9 +1407,9 @@ static int mt2701_afe_runtime_resume(struct device *dev)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					+	struct snd_soc_component *component;
 | 
				
			||||||
 | 
					 	struct mtk_base_afe *afe;
 | 
				
			||||||
 | 
					 	struct mt2701_afe_private *afe_priv;
 | 
				
			||||||
 | 
					-	struct resource *res;
 | 
				
			||||||
 | 
					 	struct device *dev;
 | 
				
			||||||
 | 
					 	int i, irq_id, ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1446,17 +1439,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 		return ret;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	afe->base_addr = devm_ioremap_resource(&pdev->dev, res);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	if (IS_ERR(afe->base_addr))
 | 
				
			||||||
 | 
					-		return PTR_ERR(afe->base_addr);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
 | 
				
			||||||
 | 
					-		&mt2701_afe_regmap_config);
 | 
				
			||||||
 | 
					-	if (IS_ERR(afe->regmap))
 | 
				
			||||||
 | 
					-		return PTR_ERR(afe->regmap);
 | 
				
			||||||
 | 
					+	afe->regmap = syscon_node_to_regmap(dev->parent->of_node);
 | 
				
			||||||
 | 
					+	if (!afe->regmap) {
 | 
				
			||||||
 | 
					+		dev_err(dev, "could not get regmap from parent\n");
 | 
				
			||||||
 | 
					+		return -ENODEV;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	mutex_init(&afe->irq_alloc_lock);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -1490,6 +1477,12 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 			= &mt2701_i2s_data[i][I2S_IN];
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	component = kzalloc(sizeof(*component), GFP_KERNEL);
 | 
				
			||||||
 | 
					+	if (!component)
 | 
				
			||||||
 | 
					+		return -ENOMEM;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	component->regmap = afe->regmap;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	afe->mtk_afe_hardware = &mt2701_afe_hardware;
 | 
				
			||||||
 | 
					 	afe->memif_fs = mt2701_memif_fs;
 | 
				
			||||||
 | 
					 	afe->irq_fs = mt2701_irq_fs;
 | 
				
			||||||
 | 
					@@ -1502,7 +1495,7 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	ret = mt2701_init_clock(afe);
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					 		dev_err(dev, "init clock error\n");
 | 
				
			||||||
 | 
					-		return ret;
 | 
				
			||||||
 | 
					+		goto err_init_clock;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	platform_set_drvdata(pdev, afe);
 | 
				
			||||||
 | 
					@@ -1521,10 +1514,10 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 		goto err_platform;
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ret = snd_soc_register_component(&pdev->dev,
 | 
				
			||||||
 | 
					-					 &mt2701_afe_pcm_dai_component,
 | 
				
			||||||
 | 
					-					 mt2701_afe_pcm_dais,
 | 
				
			||||||
 | 
					-					 ARRAY_SIZE(mt2701_afe_pcm_dais));
 | 
				
			||||||
 | 
					+	ret = snd_soc_add_component(dev, component,
 | 
				
			||||||
 | 
					+				    &mt2701_afe_pcm_dai_component,
 | 
				
			||||||
 | 
					+				    mt2701_afe_pcm_dais,
 | 
				
			||||||
 | 
					+				    ARRAY_SIZE(mt2701_afe_pcm_dais));
 | 
				
			||||||
 | 
					 	if (ret) {
 | 
				
			||||||
 | 
					 		dev_warn(dev, "err_dai_component\n");
 | 
				
			||||||
 | 
					 		goto err_dai_component;
 | 
				
			||||||
 | 
					@@ -1538,6 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	pm_runtime_put_sync(dev);
 | 
				
			||||||
 | 
					 err_pm_disable:
 | 
				
			||||||
 | 
					 	pm_runtime_disable(dev);
 | 
				
			||||||
 | 
					+err_init_clock:
 | 
				
			||||||
 | 
					+	kfree(component);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return ret;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					diff --git a/sound/soc/mediatek/mt2701/mt2701-reg.h b/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					index f17c76f37b5f..18e676974f22 100644
 | 
				
			||||||
 | 
					--- a/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					+++ b/sound/soc/mediatek/mt2701/mt2701-reg.h
 | 
				
			||||||
 | 
					@@ -145,5 +145,4 @@
 | 
				
			||||||
 | 
					 #define ASYS_I2S_CON_WIDE_MODE_SET(x)	((x) << 1)
 | 
				
			||||||
 | 
					 #define ASYS_I2S_IN_PHASE_FIX		(0x1 << 31)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#define AFE_END_ADDR 0x15e0
 | 
				
			||||||
 | 
					 #endif
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,217 @@
 | 
				
			|||||||
 | 
					From 018219d340c0f7a10098683b8a4733618ea76ba3 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Date: Thu, 4 Jan 2018 15:44:09 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 186/224] ASoC: mediatek: update MT2701 AFE documentation to
 | 
				
			||||||
 | 
					 adapt mfd device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					As the new MFD parent is in place, modify MT2701 AFE documentation to
 | 
				
			||||||
 | 
					adapt it. Also add three core clocks in example.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Mark Brown <broonie@kernel.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 .../devicetree/bindings/sound/mt2701-afe-pcm.txt   | 171 +++++++++++----------
 | 
				
			||||||
 | 
					 1 file changed, 93 insertions(+), 78 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					index 0450baad2813..6df87b97f7cb 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt
 | 
				
			||||||
 | 
					@@ -2,15 +2,17 @@ Mediatek AFE PCM controller for mt2701
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Required properties:
 | 
				
			||||||
 | 
					 - compatible = "mediatek,mt2701-audio";
 | 
				
			||||||
 | 
					-- reg: register location and size
 | 
				
			||||||
 | 
					 - interrupts: should contain AFE and ASYS interrupts
 | 
				
			||||||
 | 
					 - interrupt-names: should be "afe" and "asys"
 | 
				
			||||||
 | 
					 - power-domains: should define the power domain
 | 
				
			||||||
 | 
					 - clocks: Must contain an entry for each entry in clock-names
 | 
				
			||||||
 | 
					   See ../clocks/clock-bindings.txt for details
 | 
				
			||||||
 | 
					 - clock-names: should have these clock names:
 | 
				
			||||||
 | 
					+		"infra_sys_audio_clk",
 | 
				
			||||||
 | 
					 		"top_audio_mux1_sel",
 | 
				
			||||||
 | 
					 		"top_audio_mux2_sel",
 | 
				
			||||||
 | 
					+		"top_audio_a1sys_hp",
 | 
				
			||||||
 | 
					+		"top_audio_a2sys_hp",
 | 
				
			||||||
 | 
					 		"i2s0_src_sel",
 | 
				
			||||||
 | 
					 		"i2s1_src_sel",
 | 
				
			||||||
 | 
					 		"i2s2_src_sel",
 | 
				
			||||||
 | 
					@@ -45,85 +47,98 @@ Required properties:
 | 
				
			||||||
 | 
					 - assigned-clocks-parents: parent of input clocks of assigned clocks.
 | 
				
			||||||
 | 
					 - assigned-clock-rates: list of clock frequencies of assigned clocks.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+Must be a subnode of MediaTek audsys device tree node.
 | 
				
			||||||
 | 
					+See ../arm/mediatek/mediatek,audsys.txt for details about the parent node.
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 Example:
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	afe: mt2701-afe-pcm@11220000 {
 | 
				
			||||||
 | 
					-		compatible = "mediatek,mt2701-audio";
 | 
				
			||||||
 | 
					-		reg = <0 0x11220000 0 0x2000>,
 | 
				
			||||||
 | 
					-		      <0 0x112A0000 0 0x20000>;
 | 
				
			||||||
 | 
					-		interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
 | 
				
			||||||
 | 
					-			     <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
 | 
				
			||||||
 | 
					-		interrupt-names	= "afe", "asys";
 | 
				
			||||||
 | 
					-		power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
 | 
				
			||||||
 | 
					-		clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
 | 
				
			||||||
 | 
					-			 <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SO1>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SO2>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SO3>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SO4>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SIN1>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SIN2>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SIN3>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_I2SIN4>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_ASRCO1>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_ASRCO2>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_ASRCO3>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_ASRCO4>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_AFE>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_AFE_CONN>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_A1SYS>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_A2SYS>,
 | 
				
			||||||
 | 
					-			 <&audiosys CLK_AUD_AFE_MRGIF>;
 | 
				
			||||||
 | 
					+	audsys: audio-subsystem@11220000 {
 | 
				
			||||||
 | 
					+		compatible = "mediatek,mt2701-audsys", "syscon", "simple-mfd";
 | 
				
			||||||
 | 
					+		...
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+		afe: audio-controller {
 | 
				
			||||||
 | 
					+			compatible = "mediatek,mt2701-audio";
 | 
				
			||||||
 | 
					+			interrupts =  <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
 | 
				
			||||||
 | 
					+				      <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
 | 
				
			||||||
 | 
					+			interrupt-names	= "afe", "asys";
 | 
				
			||||||
 | 
					+			power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+			clocks = <&infracfg CLK_INFRA_AUDIO>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_48K_TIMING>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_44K_TIMING>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
 | 
				
			||||||
 | 
					+				 <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SO1>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SO2>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SO3>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SO4>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SIN1>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SIN2>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SIN3>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_I2SIN4>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_ASRCO1>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_ASRCO2>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_ASRCO3>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_ASRCO4>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_AFE>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_AFE_CONN>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_A1SYS>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_A2SYS>,
 | 
				
			||||||
 | 
					+				 <&audsys CLK_AUD_AFE_MRGIF>;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		clock-names = "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					-			      "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					-			      "i2s0_src_sel",
 | 
				
			||||||
 | 
					-			      "i2s1_src_sel",
 | 
				
			||||||
 | 
					-			      "i2s2_src_sel",
 | 
				
			||||||
 | 
					-			      "i2s3_src_sel",
 | 
				
			||||||
 | 
					-			      "i2s0_src_div",
 | 
				
			||||||
 | 
					-			      "i2s1_src_div",
 | 
				
			||||||
 | 
					-			      "i2s2_src_div",
 | 
				
			||||||
 | 
					-			      "i2s3_src_div",
 | 
				
			||||||
 | 
					-			      "i2s0_mclk_en",
 | 
				
			||||||
 | 
					-			      "i2s1_mclk_en",
 | 
				
			||||||
 | 
					-			      "i2s2_mclk_en",
 | 
				
			||||||
 | 
					-			      "i2s3_mclk_en",
 | 
				
			||||||
 | 
					-			      "i2so0_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2so1_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2so2_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2so3_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2si0_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2si1_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2si2_hop_ck",
 | 
				
			||||||
 | 
					-			      "i2si3_hop_ck",
 | 
				
			||||||
 | 
					-			      "asrc0_out_ck",
 | 
				
			||||||
 | 
					-			      "asrc1_out_ck",
 | 
				
			||||||
 | 
					-			      "asrc2_out_ck",
 | 
				
			||||||
 | 
					-			      "asrc3_out_ck",
 | 
				
			||||||
 | 
					-			      "audio_afe_pd",
 | 
				
			||||||
 | 
					-			      "audio_afe_conn_pd",
 | 
				
			||||||
 | 
					-			      "audio_a1sys_pd",
 | 
				
			||||||
 | 
					-			      "audio_a2sys_pd",
 | 
				
			||||||
 | 
					-			      "audio_mrgif_pd";
 | 
				
			||||||
 | 
					+			clock-names = "infra_sys_audio_clk",
 | 
				
			||||||
 | 
					+				      "top_audio_mux1_sel",
 | 
				
			||||||
 | 
					+				      "top_audio_mux2_sel",
 | 
				
			||||||
 | 
					+				      "top_audio_a1sys_hp",
 | 
				
			||||||
 | 
					+				      "top_audio_a2sys_hp",
 | 
				
			||||||
 | 
					+				      "i2s0_src_sel",
 | 
				
			||||||
 | 
					+				      "i2s1_src_sel",
 | 
				
			||||||
 | 
					+				      "i2s2_src_sel",
 | 
				
			||||||
 | 
					+				      "i2s3_src_sel",
 | 
				
			||||||
 | 
					+				      "i2s0_src_div",
 | 
				
			||||||
 | 
					+				      "i2s1_src_div",
 | 
				
			||||||
 | 
					+				      "i2s2_src_div",
 | 
				
			||||||
 | 
					+				      "i2s3_src_div",
 | 
				
			||||||
 | 
					+				      "i2s0_mclk_en",
 | 
				
			||||||
 | 
					+				      "i2s1_mclk_en",
 | 
				
			||||||
 | 
					+				      "i2s2_mclk_en",
 | 
				
			||||||
 | 
					+				      "i2s3_mclk_en",
 | 
				
			||||||
 | 
					+				      "i2so0_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2so1_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2so2_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2so3_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2si0_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2si1_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2si2_hop_ck",
 | 
				
			||||||
 | 
					+				      "i2si3_hop_ck",
 | 
				
			||||||
 | 
					+				      "asrc0_out_ck",
 | 
				
			||||||
 | 
					+				      "asrc1_out_ck",
 | 
				
			||||||
 | 
					+				      "asrc2_out_ck",
 | 
				
			||||||
 | 
					+				      "asrc3_out_ck",
 | 
				
			||||||
 | 
					+				      "audio_afe_pd",
 | 
				
			||||||
 | 
					+				      "audio_afe_conn_pd",
 | 
				
			||||||
 | 
					+				      "audio_a1sys_pd",
 | 
				
			||||||
 | 
					+				      "audio_a2sys_pd",
 | 
				
			||||||
 | 
					+				      "audio_mrgif_pd";
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-		assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					-				  <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					-				  <&topckgen CLK_TOP_AUD_MUX1_DIV>,
 | 
				
			||||||
 | 
					-				  <&topckgen CLK_TOP_AUD_MUX2_DIV>;
 | 
				
			||||||
 | 
					-		assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
 | 
				
			||||||
 | 
					-					 <&topckgen CLK_TOP_AUD2PLL_90M>;
 | 
				
			||||||
 | 
					-		assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
 | 
				
			||||||
 | 
					+			assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 | 
				
			||||||
 | 
					+					  <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 | 
				
			||||||
 | 
					+					  <&topckgen CLK_TOP_AUD_MUX1_DIV>,
 | 
				
			||||||
 | 
					+					  <&topckgen CLK_TOP_AUD_MUX2_DIV>;
 | 
				
			||||||
 | 
					+			assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
 | 
				
			||||||
 | 
					+						 <&topckgen CLK_TOP_AUD2PLL_90M>;
 | 
				
			||||||
 | 
					+			assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
 | 
				
			||||||
 | 
					+		};
 | 
				
			||||||
 | 
					 	};
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					From 3d5564bbc0a39ba07d1bbdaec1f69a3d39c4495e Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 3 Jan 2018 16:53:17 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 187/224] usb: mtu3: fix error code for getting extcon device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					When failing to get extcon device, extcon_get_edev_by_phandle()
 | 
				
			||||||
 | 
					may return different error codes, but not only -EPROBE_DEFER,
 | 
				
			||||||
 | 
					so can't always return -EPROBE_DEFER, and fix it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/usb/mtu3/mtu3_plat.c | 2 +-
 | 
				
			||||||
 | 
					 1 file changed, 1 insertion(+), 1 deletion(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index 9ff33579b42e..a2523ead46cf 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					@@ -317,7 +317,7 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 		otg_sx->edev = extcon_get_edev_by_phandle(ssusb->dev, 0);
 | 
				
			||||||
 | 
					 		if (IS_ERR(otg_sx->edev)) {
 | 
				
			||||||
 | 
					 			dev_err(ssusb->dev, "couldn't get extcon device\n");
 | 
				
			||||||
 | 
					-			return -EPROBE_DEFER;
 | 
				
			||||||
 | 
					+			return PTR_ERR(otg_sx->edev);
 | 
				
			||||||
 | 
					 		}
 | 
				
			||||||
 | 
					 	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,245 @@
 | 
				
			|||||||
 | 
					From 354655aaf0f71ce2b567cbc02afb0664c99e434e Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 3 Jan 2018 16:53:18 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 188/224] usb: mtu3: supports remote wakeup for mt2712 with two
 | 
				
			||||||
 | 
					 SSUSB IPs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The old way of usb wakeup only supports platform with single SSUSB IP,
 | 
				
			||||||
 | 
					such as mt8173, but mt2712 has two SSUSB IPs, so rebuild its flow and
 | 
				
			||||||
 | 
					also supports the new glue layer of usb wakeup on mt2712 which is
 | 
				
			||||||
 | 
					different from mt8173.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/usb/mtu3/mtu3.h      |  11 +++--
 | 
				
			||||||
 | 
					 drivers/usb/mtu3/mtu3_dr.h   |   3 +-
 | 
				
			||||||
 | 
					 drivers/usb/mtu3/mtu3_host.c | 115 +++++++++++++++++++++----------------------
 | 
				
			||||||
 | 
					 drivers/usb/mtu3/mtu3_plat.c |   8 +--
 | 
				
			||||||
 | 
					 4 files changed, 70 insertions(+), 67 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					index d80e4e813248..ed3aec46eda1 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3.h
 | 
				
			||||||
 | 
					@@ -238,7 +238,10 @@ struct otg_switch_mtk {
 | 
				
			||||||
 | 
					  * @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
 | 
				
			||||||
 | 
					+ * @uwk_en: it's true when supports remote wakeup in host mode
 | 
				
			||||||
 | 
					+ * @uwk: syscon including usb wakeup glue layer between SSUSB IP and SPM
 | 
				
			||||||
 | 
					+ * @uwk_reg_base: the base address of the wakeup glue layer in @uwk
 | 
				
			||||||
 | 
					+ * @uwk_vers: the version of the wakeup glue layer
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					 struct ssusb_mtk {
 | 
				
			||||||
 | 
					 	struct device *dev;
 | 
				
			||||||
 | 
					@@ -262,8 +265,10 @@ struct ssusb_mtk {
 | 
				
			||||||
 | 
					 	int u3p_dis_msk;
 | 
				
			||||||
 | 
					 	struct dentry *dbgfs_root;
 | 
				
			||||||
 | 
					 	/* usb wakeup for host mode */
 | 
				
			||||||
 | 
					-	bool wakeup_en;
 | 
				
			||||||
 | 
					-	struct regmap *pericfg;
 | 
				
			||||||
 | 
					+	bool uwk_en;
 | 
				
			||||||
 | 
					+	struct regmap *uwk;
 | 
				
			||||||
 | 
					+	u32 uwk_reg_base;
 | 
				
			||||||
 | 
					+	u32 uwk_vers;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /**
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_dr.h b/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					index 0f0cbac00192..1fa62ce136b6 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_dr.h
 | 
				
			||||||
 | 
					@@ -27,8 +27,7 @@ int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
 | 
				
			||||||
 | 
					 				struct device_node *dn);
 | 
				
			||||||
 | 
					 int ssusb_host_enable(struct ssusb_mtk *ssusb);
 | 
				
			||||||
 | 
					 int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend);
 | 
				
			||||||
 | 
					-int ssusb_wakeup_enable(struct ssusb_mtk *ssusb);
 | 
				
			||||||
 | 
					-void ssusb_wakeup_disable(struct ssusb_mtk *ssusb);
 | 
				
			||||||
 | 
					+void ssusb_wakeup_set(struct ssusb_mtk *ssusb, bool enable);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #else
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					index ec76b86dd887..1a1b6cf432a1 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_host.c
 | 
				
			||||||
 | 
					@@ -27,66 +27,77 @@
 | 
				
			||||||
 | 
					 #include "mtu3.h"
 | 
				
			||||||
 | 
					 #include "mtu3_dr.h"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#define PERI_WK_CTRL1		0x404
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_C(x)	(((x) & 0xf) << 26)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_E		BIT(25)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_C(x)	(((x) & 0xf) << 11)  /* cycle debounce */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_E	BIT(10) /* enable debounce */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_P	BIT(9)  /* polarity */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_P		BIT(6)  /* polarity for ip sleep */
 | 
				
			||||||
 | 
					+/* mt8173 etc */
 | 
				
			||||||
 | 
					+#define PERI_WK_CTRL1	0x4
 | 
				
			||||||
 | 
					+#define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
 | 
				
			||||||
 | 
					+#define WC1_IS_EN	BIT(25)
 | 
				
			||||||
 | 
					+#define WC1_IS_P	BIT(6)  /* polarity for ip sleep */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* mt2712 etc */
 | 
				
			||||||
 | 
					+#define PERI_SSUSB_SPM_CTRL	0x0
 | 
				
			||||||
 | 
					+#define SSC_IP_SLEEP_EN	BIT(4)
 | 
				
			||||||
 | 
					+#define SSC_SPM_INT_EN		BIT(1)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+enum ssusb_uwk_vers {
 | 
				
			||||||
 | 
					+	SSUSB_UWK_V1 = 1,
 | 
				
			||||||
 | 
					+	SSUSB_UWK_V2,
 | 
				
			||||||
 | 
					+};
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /*
 | 
				
			||||||
 | 
					  * ip-sleep wakeup mode:
 | 
				
			||||||
 | 
					  * all clocks can be turn off, but power domain should be kept on
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					-static void ssusb_wakeup_ip_sleep_en(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					+static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					-	struct regmap *pericfg = ssusb->pericfg;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_IS_P;
 | 
				
			||||||
 | 
					-	tmp &= ~(UWK_CTL1_IS_C(0xf));
 | 
				
			||||||
 | 
					-	tmp |= UWK_CTL1_IS_C(0x8);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_IS_E);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	dev_dbg(ssusb->dev, "%s(): WK_CTRL1[P6,E25,C26:29]=%#x\n",
 | 
				
			||||||
 | 
					-		__func__, tmp);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-static void ssusb_wakeup_ip_sleep_dis(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_read(ssusb->pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_IS_E;
 | 
				
			||||||
 | 
					-	regmap_write(ssusb->pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					+	u32 reg, msk, val;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	switch (ssusb->uwk_vers) {
 | 
				
			||||||
 | 
					+	case SSUSB_UWK_V1:
 | 
				
			||||||
 | 
					+		reg = ssusb->uwk_reg_base + PERI_WK_CTRL1;
 | 
				
			||||||
 | 
					+		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
 | 
				
			||||||
 | 
					+		val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
 | 
				
			||||||
 | 
					+		break;
 | 
				
			||||||
 | 
					+	case SSUSB_UWK_V2:
 | 
				
			||||||
 | 
					+		reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
 | 
				
			||||||
 | 
					+		msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
 | 
				
			||||||
 | 
					+		val = enable ? msk : 0;
 | 
				
			||||||
 | 
					+		break;
 | 
				
			||||||
 | 
					+	default:
 | 
				
			||||||
 | 
					+		return;
 | 
				
			||||||
 | 
					+	};
 | 
				
			||||||
 | 
					+	regmap_update_bits(ssusb->uwk, reg, msk, val);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
 | 
				
			||||||
 | 
					 				struct device_node *dn)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct device *dev = ssusb->dev;
 | 
				
			||||||
 | 
					+	struct of_phandle_args args;
 | 
				
			||||||
 | 
					+	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	/*
 | 
				
			||||||
 | 
					-	 * Wakeup function is optional, so it is not an error if this property
 | 
				
			||||||
 | 
					-	 * does not exist, and in such case, no need to get relative
 | 
				
			||||||
 | 
					-	 * properties anymore.
 | 
				
			||||||
 | 
					-	 */
 | 
				
			||||||
 | 
					-	ssusb->wakeup_en = of_property_read_bool(dn, "mediatek,enable-wakeup");
 | 
				
			||||||
 | 
					-	if (!ssusb->wakeup_en)
 | 
				
			||||||
 | 
					+	/* wakeup function is optional */
 | 
				
			||||||
 | 
					+	ssusb->uwk_en = of_property_read_bool(dn, "wakeup-source");
 | 
				
			||||||
 | 
					+	if (!ssusb->uwk_en)
 | 
				
			||||||
 | 
					 		return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
 | 
				
			||||||
 | 
					-						"mediatek,syscon-wakeup");
 | 
				
			||||||
 | 
					-	if (IS_ERR(ssusb->pericfg)) {
 | 
				
			||||||
 | 
					-		dev_err(dev, "fail to get pericfg regs\n");
 | 
				
			||||||
 | 
					-		return PTR_ERR(ssusb->pericfg);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					+	ret = of_parse_phandle_with_fixed_args(dn,
 | 
				
			||||||
 | 
					+				"mediatek,syscon-wakeup", 2, 0, &args);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					+	ssusb->uwk_reg_base = args.args[0];
 | 
				
			||||||
 | 
					+	ssusb->uwk_vers = args.args[1];
 | 
				
			||||||
 | 
					+	ssusb->uwk = syscon_node_to_regmap(args.np);
 | 
				
			||||||
 | 
					+	of_node_put(args.np);
 | 
				
			||||||
 | 
					+	dev_info(ssusb->dev, "uwk - reg:0x%x, version:%d\n",
 | 
				
			||||||
 | 
					+			ssusb->uwk_reg_base, ssusb->uwk_vers);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	return PTR_ERR_OR_ZERO(ssusb->uwk);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+void ssusb_wakeup_set(struct ssusb_mtk *ssusb, bool enable)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+	if (ssusb->uwk_en)
 | 
				
			||||||
 | 
					+		ssusb_wakeup_ip_sleep_set(ssusb, enable);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static void host_ports_num_get(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					@@ -244,17 +255,3 @@ void ssusb_host_exit(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 	of_platform_depopulate(ssusb->dev);
 | 
				
			||||||
 | 
					 	ssusb_host_cleanup(ssusb);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	if (ssusb->wakeup_en)
 | 
				
			||||||
 | 
					-		ssusb_wakeup_ip_sleep_en(ssusb);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-void ssusb_wakeup_disable(struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	if (ssusb->wakeup_en)
 | 
				
			||||||
 | 
					-		ssusb_wakeup_ip_sleep_dis(ssusb);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					index a2523ead46cf..4cafd4ca8457 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/mtu3/mtu3_plat.c
 | 
				
			||||||
 | 
					@@ -291,8 +291,10 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* if host role is supported */
 | 
				
			||||||
 | 
					 	ret = ssusb_wakeup_of_property_parse(ssusb, node);
 | 
				
			||||||
 | 
					-	if (ret)
 | 
				
			||||||
 | 
					+	if (ret) {
 | 
				
			||||||
 | 
					+		dev_err(dev, "failed to parse uwk property\n");
 | 
				
			||||||
 | 
					 		return ret;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* optional property, ignore the error if it does not exist */
 | 
				
			||||||
 | 
					 	of_property_read_u32(node, "mediatek,u3p-dis-msk",
 | 
				
			||||||
 | 
					@@ -466,7 +468,7 @@ static int __maybe_unused mtu3_suspend(struct device *dev)
 | 
				
			||||||
 | 
					 	ssusb_host_disable(ssusb, true);
 | 
				
			||||||
 | 
					 	ssusb_phy_power_off(ssusb);
 | 
				
			||||||
 | 
					 	ssusb_clks_disable(ssusb);
 | 
				
			||||||
 | 
					-	ssusb_wakeup_enable(ssusb);
 | 
				
			||||||
 | 
					+	ssusb_wakeup_set(ssusb, true);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					@@ -482,7 +484,7 @@ static int __maybe_unused mtu3_resume(struct device *dev)
 | 
				
			||||||
 | 
					 	if (!ssusb->is_host)
 | 
				
			||||||
 | 
					 		return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	ssusb_wakeup_disable(ssusb);
 | 
				
			||||||
 | 
					+	ssusb_wakeup_set(ssusb, false);
 | 
				
			||||||
 | 
					 	ret = ssusb_clks_enable(ssusb);
 | 
				
			||||||
 | 
					 	if (ret)
 | 
				
			||||||
 | 
					 		goto clks_err;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					From 067ad5fd18e2e7e38b77ca94eebaaf8d9a35d842 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 3 Jan 2018 16:53:19 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 189/224] dt-bindings: usb: mtu3: update USB wakeup properties
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Add two arguments in "mediatek,syscon-wakeup" to support multi
 | 
				
			||||||
 | 
					wakeup glue layer between SSUSB and SPM, and use standard property
 | 
				
			||||||
 | 
					"wakeup-source" to replace the private "mediatek,enable-wakeup"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Reviewed-by: Rob Herring <robh@kernel.org>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 15 ++++++++++-----
 | 
				
			||||||
 | 
					 1 file changed, 10 insertions(+), 5 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					index b2271d8e6b50..d589a1ef96a1 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 | 
				
			||||||
 | 
					@@ -42,9 +42,14 @@ Optional properties:
 | 
				
			||||||
 | 
					  - enable-manual-drd : supports manual dual-role switch via debugfs; usually
 | 
				
			||||||
 | 
					 	used when receptacle is TYPE-A and also wants to support dual-role
 | 
				
			||||||
 | 
					 	mode.
 | 
				
			||||||
 | 
					- - 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".
 | 
				
			||||||
 | 
					+ - wakeup-source: enable USB remote wakeup of host mode.
 | 
				
			||||||
 | 
					+ - mediatek,syscon-wakeup : phandle to syscon used to access the register
 | 
				
			||||||
 | 
					+	of the USB wakeup glue layer between SSUSB and SPM; it depends on
 | 
				
			||||||
 | 
					+	"wakeup-source", and has two arguments:
 | 
				
			||||||
 | 
					+	- the first one : register base address of the glue layer in syscon;
 | 
				
			||||||
 | 
					+	- the second one : hardware version of the glue layer
 | 
				
			||||||
 | 
					+		- 1 : used by mt8173 etc
 | 
				
			||||||
 | 
					+		- 2 : used by mt2712 etc
 | 
				
			||||||
 | 
					  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 | 
				
			||||||
 | 
					 	bit1 for u3port1, ... etc;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -71,8 +76,8 @@ ssusb: usb@11271000 {
 | 
				
			||||||
 | 
					 	vbus-supply = <&usb_p0_vbus>;
 | 
				
			||||||
 | 
					 	extcon = <&extcon_usb>;
 | 
				
			||||||
 | 
					 	dr_mode = "otg";
 | 
				
			||||||
 | 
					-	mediatek,enable-wakeup;
 | 
				
			||||||
 | 
					-	mediatek,syscon-wakeup = <&pericfg>;
 | 
				
			||||||
 | 
					+	wakeup-source;
 | 
				
			||||||
 | 
					+	mediatek,syscon-wakeup = <&pericfg 0x400 1>;
 | 
				
			||||||
 | 
					 	#address-cells = <2>;
 | 
				
			||||||
 | 
					 	#size-cells = <2>;
 | 
				
			||||||
 | 
					 	ranges;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,273 @@
 | 
				
			|||||||
 | 
					From e6fe50ef22071fe87ce48f79ab4fe21cbec2081b Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 3 Jan 2018 16:53:20 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 190/224] usb: xhci-mtk: supports remote wakeup for mt2712 with
 | 
				
			||||||
 | 
					 two xHCI IPs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The old way of usb wakeup only supports platform with single xHCI IP,
 | 
				
			||||||
 | 
					such as mt8173, but mt2712 has two xHCI IPs, so rebuild its flow and
 | 
				
			||||||
 | 
					supports the new glue layer of usb wakeup on mt2712 which is different
 | 
				
			||||||
 | 
					from mt8173.
 | 
				
			||||||
 | 
					Due to there is a hardware bug with the LINE STATE wakeup mode on
 | 
				
			||||||
 | 
					mt8173 which causes wakeup failure by low speed devices, and also
 | 
				
			||||||
 | 
					because IP SLEEP mode can cover all functions of LINE STATE mode,
 | 
				
			||||||
 | 
					it is unused in fact, and will not support it later, so remove it at
 | 
				
			||||||
 | 
					the same time.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci-mtk.c | 177 +++++++++++++++-----------------------------
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci-mtk.h |   6 +-
 | 
				
			||||||
 | 
					 2 files changed, 65 insertions(+), 118 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index e5caabe7eebe..8e51b3fec386 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					@@ -66,26 +66,21 @@
 | 
				
			||||||
 | 
					 /* u2_phy_pll register */
 | 
				
			||||||
 | 
					 #define CTRL_U2_FORCE_PLL_STB	BIT(28)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#define PERI_WK_CTRL0		0x400
 | 
				
			||||||
 | 
					-#define UWK_CTR0_0P_LS_PE	BIT(8)  /* posedge */
 | 
				
			||||||
 | 
					-#define UWK_CTR0_0P_LS_NE	BIT(7)  /* negedge for 0p linestate*/
 | 
				
			||||||
 | 
					-#define UWK_CTL1_1P_LS_C(x)	(((x) & 0xf) << 1)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_1P_LS_E	BIT(0)
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-#define PERI_WK_CTRL1		0x404
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_C(x)	(((x) & 0xf) << 26)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_E		BIT(25)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_0P_LS_C(x)	(((x) & 0xf) << 21)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_0P_LS_E	BIT(20)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_C(x)	(((x) & 0xf) << 11)  /* cycle debounce */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_E	BIT(10) /* enable debounce */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IDDIG_P	BIT(9)  /* polarity */
 | 
				
			||||||
 | 
					-#define UWK_CTL1_0P_LS_P	BIT(7)
 | 
				
			||||||
 | 
					-#define UWK_CTL1_IS_P		BIT(6)  /* polarity for ip sleep */
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-enum ssusb_wakeup_src {
 | 
				
			||||||
 | 
					-	SSUSB_WK_IP_SLEEP = 1,
 | 
				
			||||||
 | 
					-	SSUSB_WK_LINE_STATE = 2,
 | 
				
			||||||
 | 
					+/* usb remote wakeup registers in syscon */
 | 
				
			||||||
 | 
					+/* mt8173 etc */
 | 
				
			||||||
 | 
					+#define PERI_WK_CTRL1	0x4
 | 
				
			||||||
 | 
					+#define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
 | 
				
			||||||
 | 
					+#define WC1_IS_EN	BIT(25)
 | 
				
			||||||
 | 
					+#define WC1_IS_P	BIT(6)  /* polarity for ip sleep */
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+/* mt2712 etc */
 | 
				
			||||||
 | 
					+#define PERI_SSUSB_SPM_CTRL	0x0
 | 
				
			||||||
 | 
					+#define SSC_IP_SLEEP_EN	BIT(4)
 | 
				
			||||||
 | 
					+#define SSC_SPM_INT_EN		BIT(1)
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+enum ssusb_uwk_vers {
 | 
				
			||||||
 | 
					+	SSUSB_UWK_V1 = 1,
 | 
				
			||||||
 | 
					+	SSUSB_UWK_V2,
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					@@ -308,112 +303,58 @@ static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 /* only clocks can be turn off for ip-sleep wakeup mode */
 | 
				
			||||||
 | 
					-static void usb_wakeup_ip_sleep_en(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					+static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					-	struct regmap *pericfg = mtk->pericfg;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_IS_P;
 | 
				
			||||||
 | 
					-	tmp &= ~(UWK_CTL1_IS_C(0xf));
 | 
				
			||||||
 | 
					-	tmp |= UWK_CTL1_IS_C(0x8);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_IS_E);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	dev_dbg(mtk->dev, "%s(): WK_CTRL1[P6,E25,C26:29]=%#x\n",
 | 
				
			||||||
 | 
					-		__func__, tmp);
 | 
				
			||||||
 | 
					+	u32 reg, msk, val;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	switch (mtk->uwk_vers) {
 | 
				
			||||||
 | 
					+	case SSUSB_UWK_V1:
 | 
				
			||||||
 | 
					+		reg = mtk->uwk_reg_base + PERI_WK_CTRL1;
 | 
				
			||||||
 | 
					+		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
 | 
				
			||||||
 | 
					+		val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
 | 
				
			||||||
 | 
					+		break;
 | 
				
			||||||
 | 
					+	case SSUSB_UWK_V2:
 | 
				
			||||||
 | 
					+		reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
 | 
				
			||||||
 | 
					+		msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
 | 
				
			||||||
 | 
					+		val = enable ? msk : 0;
 | 
				
			||||||
 | 
					+		break;
 | 
				
			||||||
 | 
					+	default:
 | 
				
			||||||
 | 
					+		return;
 | 
				
			||||||
 | 
					+	};
 | 
				
			||||||
 | 
					+	regmap_update_bits(mtk->uwk, reg, msk, val);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static void usb_wakeup_ip_sleep_dis(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					+static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk,
 | 
				
			||||||
 | 
					+				struct device_node *dn)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					+	struct of_phandle_args args;
 | 
				
			||||||
 | 
					+	int ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	regmap_read(mtk->pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_IS_E;
 | 
				
			||||||
 | 
					-	regmap_write(mtk->pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+	/* Wakeup function is optional */
 | 
				
			||||||
 | 
					+	mtk->uwk_en = of_property_read_bool(dn, "wakeup-source");
 | 
				
			||||||
 | 
					+	if (!mtk->uwk_en)
 | 
				
			||||||
 | 
					+		return 0;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-/*
 | 
				
			||||||
 | 
					-* for line-state wakeup mode, phy's power should not power-down
 | 
				
			||||||
 | 
					-* and only support cable plug in/out
 | 
				
			||||||
 | 
					-*/
 | 
				
			||||||
 | 
					-static void usb_wakeup_line_state_en(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					-	struct regmap *pericfg = mtk->pericfg;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* line-state of u2-port0 */
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_0P_LS_P;
 | 
				
			||||||
 | 
					-	tmp &= ~(UWK_CTL1_0P_LS_C(0xf));
 | 
				
			||||||
 | 
					-	tmp |= UWK_CTL1_0P_LS_C(0x8);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_0P_LS_E);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* line-state of u2-port1 */
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL0, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~(UWK_CTL1_1P_LS_C(0xf));
 | 
				
			||||||
 | 
					-	tmp |= UWK_CTL1_1P_LS_C(0x8);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL0, tmp);
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL0, tmp | UWK_CTL1_1P_LS_E);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+	ret = of_parse_phandle_with_fixed_args(dn,
 | 
				
			||||||
 | 
					+				"mediatek,syscon-wakeup", 2, 0, &args);
 | 
				
			||||||
 | 
					+	if (ret)
 | 
				
			||||||
 | 
					+		return ret;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static void usb_wakeup_line_state_dis(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	u32 tmp;
 | 
				
			||||||
 | 
					-	struct regmap *pericfg = mtk->pericfg;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* line-state of u2-port0 */
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL1, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_0P_LS_E;
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL1, tmp);
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/* line-state of u2-port1 */
 | 
				
			||||||
 | 
					-	regmap_read(pericfg, PERI_WK_CTRL0, &tmp);
 | 
				
			||||||
 | 
					-	tmp &= ~UWK_CTL1_1P_LS_E;
 | 
				
			||||||
 | 
					-	regmap_write(pericfg, PERI_WK_CTRL0, tmp);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+	mtk->uwk_reg_base = args.args[0];
 | 
				
			||||||
 | 
					+	mtk->uwk_vers = args.args[1];
 | 
				
			||||||
 | 
					+	mtk->uwk = syscon_node_to_regmap(args.np);
 | 
				
			||||||
 | 
					+	of_node_put(args.np);
 | 
				
			||||||
 | 
					+	dev_info(mtk->dev, "uwk - reg:0x%x, version:%d\n",
 | 
				
			||||||
 | 
					+			mtk->uwk_reg_base, mtk->uwk_vers);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
 | 
				
			||||||
 | 
					-		usb_wakeup_ip_sleep_en(mtk);
 | 
				
			||||||
 | 
					-	else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE)
 | 
				
			||||||
 | 
					-		usb_wakeup_line_state_en(mtk);
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					+	return PTR_ERR_OR_ZERO(mtk->uwk);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-	if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
 | 
				
			||||||
 | 
					-		usb_wakeup_ip_sleep_dis(mtk);
 | 
				
			||||||
 | 
					-	else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE)
 | 
				
			||||||
 | 
					-		usb_wakeup_line_state_dis(mtk);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk,
 | 
				
			||||||
 | 
					-				struct device_node *dn)
 | 
				
			||||||
 | 
					+static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-	struct device *dev = mtk->dev;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	/*
 | 
				
			||||||
 | 
					-	* wakeup function is optional, so it is not an error if this property
 | 
				
			||||||
 | 
					-	* does not exist, and in such case, no need to get relative
 | 
				
			||||||
 | 
					-	* properties anymore.
 | 
				
			||||||
 | 
					-	*/
 | 
				
			||||||
 | 
					-	of_property_read_u32(dn, "mediatek,wakeup-src", &mtk->wakeup_src);
 | 
				
			||||||
 | 
					-	if (!mtk->wakeup_src)
 | 
				
			||||||
 | 
					-		return 0;
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	mtk->pericfg = syscon_regmap_lookup_by_phandle(dn,
 | 
				
			||||||
 | 
					-						"mediatek,syscon-wakeup");
 | 
				
			||||||
 | 
					-	if (IS_ERR(mtk->pericfg)) {
 | 
				
			||||||
 | 
					-		dev_err(dev, "fail to get pericfg regs\n");
 | 
				
			||||||
 | 
					-		return PTR_ERR(mtk->pericfg);
 | 
				
			||||||
 | 
					-	}
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					-	return 0;
 | 
				
			||||||
 | 
					+	if (mtk->uwk_en)
 | 
				
			||||||
 | 
					+		usb_wakeup_ip_sleep_set(mtk, enable);
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static int xhci_mtk_setup(struct usb_hcd *hcd);
 | 
				
			||||||
 | 
					@@ -595,8 +536,10 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 			     &mtk->u3p_dis_msk);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	ret = usb_wakeup_of_property_parse(mtk, node);
 | 
				
			||||||
 | 
					-	if (ret)
 | 
				
			||||||
 | 
					+	if (ret) {
 | 
				
			||||||
 | 
					+		dev_err(dev, "failed to parse uwk property\n");
 | 
				
			||||||
 | 
					 		return ret;
 | 
				
			||||||
 | 
					+	}
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	mtk->num_phys = of_count_phandle_with_args(node,
 | 
				
			||||||
 | 
					 			"phys", "#phy-cells");
 | 
				
			||||||
 | 
					@@ -780,7 +723,7 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev)
 | 
				
			||||||
 | 
					 	xhci_mtk_host_disable(mtk);
 | 
				
			||||||
 | 
					 	xhci_mtk_phy_power_off(mtk);
 | 
				
			||||||
 | 
					 	xhci_mtk_clks_disable(mtk);
 | 
				
			||||||
 | 
					-	usb_wakeup_enable(mtk);
 | 
				
			||||||
 | 
					+	usb_wakeup_set(mtk, true);
 | 
				
			||||||
 | 
					 	return 0;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -790,7 +733,7 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
 | 
				
			||||||
 | 
					 	struct usb_hcd *hcd = mtk->hcd;
 | 
				
			||||||
 | 
					 	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	usb_wakeup_disable(mtk);
 | 
				
			||||||
 | 
					+	usb_wakeup_set(mtk, false);
 | 
				
			||||||
 | 
					 	xhci_mtk_clks_enable(mtk);
 | 
				
			||||||
 | 
					 	xhci_mtk_phy_power_on(mtk);
 | 
				
			||||||
 | 
					 	xhci_mtk_host_enable(mtk);
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					index 45ff5c67efb5..85c007ee1f52 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-mtk.h
 | 
				
			||||||
 | 
					@@ -131,8 +131,12 @@ struct xhci_hcd_mtk {
 | 
				
			||||||
 | 
					 	struct regmap *pericfg;
 | 
				
			||||||
 | 
					 	struct phy **phys;
 | 
				
			||||||
 | 
					 	int num_phys;
 | 
				
			||||||
 | 
					-	int wakeup_src;
 | 
				
			||||||
 | 
					 	bool lpm_support;
 | 
				
			||||||
 | 
					+	/* usb remote wakeup */
 | 
				
			||||||
 | 
					+	bool uwk_en;
 | 
				
			||||||
 | 
					+	struct regmap *uwk;
 | 
				
			||||||
 | 
					+	u32 uwk_reg_base;
 | 
				
			||||||
 | 
					+	u32 uwk_vers;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,155 @@
 | 
				
			|||||||
 | 
					From c5c72d252dc8e417388386d5767ea790ee8f5b44 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Adam Wallis <awallis@codeaurora.org>
 | 
				
			||||||
 | 
					Date: Fri, 8 Dec 2017 17:59:13 +0200
 | 
				
			||||||
 | 
					Subject: [PATCH 191/224] usb: xhci: allow imod-interval to be configurable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The xHCI driver currently has the IMOD set to 160, which
 | 
				
			||||||
 | 
					translates to an IMOD interval of 40,000ns (160 * 250)ns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Commit 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
 | 
				
			||||||
 | 
					introduced a QUIRK for the MTK platform to adjust this interval to 20,
 | 
				
			||||||
 | 
					which translates to an IMOD interval of 5,000ns (20 * 250)ns. This is
 | 
				
			||||||
 | 
					due to the fact that the MTK controller IMOD interval is 8 times
 | 
				
			||||||
 | 
					as much as defined in xHCI spec.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Instead of adding more quirk bits for additional platforms, this patch
 | 
				
			||||||
 | 
					introduces the ability for vendors to set the IMOD_INTERVAL as is
 | 
				
			||||||
 | 
					optimal for their platform. By using device_property_read_u32() on
 | 
				
			||||||
 | 
					"imod-interval-ns", the IMOD INTERVAL can be specified in nano seconds.
 | 
				
			||||||
 | 
					If no interval is specified, the default of 40,000ns (IMOD=160) will be
 | 
				
			||||||
 | 
					used.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					No bounds checking has been implemented due to the fact that a vendor
 | 
				
			||||||
 | 
					may have violated the spec and would need to specify a value outside of
 | 
				
			||||||
 | 
					the max 8,000 IRQs/second limit specified in the xHCI spec.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Tested-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Reviewed-by: Rob Herring <robh@kernel.org>
 | 
				
			||||||
 | 
					Signed-off-by: Adam Wallis <awallis@codeaurora.org>
 | 
				
			||||||
 | 
					Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt | 2 ++
 | 
				
			||||||
 | 
					 Documentation/devicetree/bindings/usb/usb-xhci.txt          | 1 +
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci-mtk.c                                 | 9 +++++++++
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci-pci.c                                 | 3 +++
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci-plat.c                                | 5 +++++
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci.c                                     | 6 +-----
 | 
				
			||||||
 | 
					 drivers/usb/host/xhci.h                                     | 2 ++
 | 
				
			||||||
 | 
					 7 files changed, 23 insertions(+), 5 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					index 30595964876a..9ff560298498 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					@@ -46,6 +46,7 @@ Optional properties:
 | 
				
			||||||
 | 
					  - pinctrl-names : a pinctrl state named "default" must be defined
 | 
				
			||||||
 | 
					  - pinctrl-0 : pin control group
 | 
				
			||||||
 | 
					 	See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
 | 
				
			||||||
 | 
					+ - imod-interval-ns: default interrupt moderation interval is 5000ns
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Example:
 | 
				
			||||||
 | 
					 usb30: usb@11270000 {
 | 
				
			||||||
 | 
					@@ -66,6 +67,7 @@ usb30: usb@11270000 {
 | 
				
			||||||
 | 
					 	usb3-lpm-capable;
 | 
				
			||||||
 | 
					 	mediatek,syscon-wakeup = <&pericfg>;
 | 
				
			||||||
 | 
					 	mediatek,wakeup-src = <1>;
 | 
				
			||||||
 | 
					+	imod-interval-ns = <10000>;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 2nd: dual-role mode with xHCI driver
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
 | 
				
			||||||
 | 
					index 2d80b60eeabe..2390ae58636b 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
 | 
				
			||||||
 | 
					@@ -28,6 +28,7 @@ Optional properties:
 | 
				
			||||||
 | 
					   - clocks: reference to a clock
 | 
				
			||||||
 | 
					   - usb3-lpm-capable: determines if platform is USB3 LPM capable
 | 
				
			||||||
 | 
					   - quirk-broken-port-ped: set if the controller has broken port disable mechanism
 | 
				
			||||||
 | 
					+  - imod-interval-ns: default interrupt moderation interval is 5000ns
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Example:
 | 
				
			||||||
 | 
					 	usb@f0931000 {
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					index 8e51b3fec386..8e4495be6592 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-mtk.c
 | 
				
			||||||
 | 
					@@ -629,6 +629,15 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	xhci = hcd_to_xhci(hcd);
 | 
				
			||||||
 | 
					 	xhci->main_hcd = hcd;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+	/*
 | 
				
			||||||
 | 
					+	 * imod_interval is the interrupt moderation value in nanoseconds.
 | 
				
			||||||
 | 
					+	 * The increment interval is 8 times as much as that defined in
 | 
				
			||||||
 | 
					+	 * the xHCI spec on MTK's controller.
 | 
				
			||||||
 | 
					+	 */
 | 
				
			||||||
 | 
					+	xhci->imod_interval = 5000;
 | 
				
			||||||
 | 
					+	device_property_read_u32(dev, "imod-interval-ns", &xhci->imod_interval);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	xhci->shared_hcd = usb_create_shared_hcd(driver, dev,
 | 
				
			||||||
 | 
					 			dev_name(dev), hcd);
 | 
				
			||||||
 | 
					 	if (!xhci->shared_hcd) {
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
 | 
				
			||||||
 | 
					index 8071c8fdd15e..cdd7d7bdfc0f 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-pci.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-pci.c
 | 
				
			||||||
 | 
					@@ -258,6 +258,9 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
 | 
				
			||||||
 | 
					 	if (!xhci->sbrn)
 | 
				
			||||||
 | 
					 		pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	/* imod_interval is the interrupt moderation value in nanoseconds. */
 | 
				
			||||||
 | 
					+	xhci->imod_interval = 40000;
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	retval = xhci_gen_setup(hcd, xhci_pci_quirks);
 | 
				
			||||||
 | 
					 	if (retval)
 | 
				
			||||||
 | 
					 		return retval;
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 | 
				
			||||||
 | 
					index 163bafde709f..47230453a876 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci-plat.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci-plat.c
 | 
				
			||||||
 | 
					@@ -265,6 +265,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					 	if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
 | 
				
			||||||
 | 
					 		xhci->quirks |= XHCI_BROKEN_PORT_PED;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+	/* imod_interval is the interrupt moderation value in nanoseconds. */
 | 
				
			||||||
 | 
					+	xhci->imod_interval = 40000;
 | 
				
			||||||
 | 
					+	device_property_read_u32(sysdev, "imod-interval-ns",
 | 
				
			||||||
 | 
					+				 &xhci->imod_interval);
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 	hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
 | 
				
			||||||
 | 
					 	if (IS_ERR(hcd->usb_phy)) {
 | 
				
			||||||
 | 
					 		ret = PTR_ERR(hcd->usb_phy);
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
 | 
				
			||||||
 | 
					index b2ff1ff1a02f..ac1b26a81e77 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci.c
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci.c
 | 
				
			||||||
 | 
					@@ -597,11 +597,7 @@ int xhci_run(struct usb_hcd *hcd)
 | 
				
			||||||
 | 
					 			"// Set the interrupt modulation register");
 | 
				
			||||||
 | 
					 	temp = readl(&xhci->ir_set->irq_control);
 | 
				
			||||||
 | 
					 	temp &= ~ER_IRQ_INTERVAL_MASK;
 | 
				
			||||||
 | 
					-	/*
 | 
				
			||||||
 | 
					-	 * the increment interval is 8 times as much as that defined
 | 
				
			||||||
 | 
					-	 * in xHCI spec on MTK's controller
 | 
				
			||||||
 | 
					-	 */
 | 
				
			||||||
 | 
					-	temp |= (u32) ((xhci->quirks & XHCI_MTK_HOST) ? 20 : 160);
 | 
				
			||||||
 | 
					+	temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK;
 | 
				
			||||||
 | 
					 	writel(temp, &xhci->ir_set->irq_control);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	/* Set the HCD state before we enable the irqs */
 | 
				
			||||||
 | 
					diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
 | 
				
			||||||
 | 
					index 2abaa4d6d39d..614380af0f96 100644
 | 
				
			||||||
 | 
					--- a/drivers/usb/host/xhci.h
 | 
				
			||||||
 | 
					+++ b/drivers/usb/host/xhci.h
 | 
				
			||||||
 | 
					@@ -1723,6 +1723,8 @@ struct xhci_hcd {
 | 
				
			||||||
 | 
					 	u8		max_interrupters;
 | 
				
			||||||
 | 
					 	u8		max_ports;
 | 
				
			||||||
 | 
					 	u8		isoc_threshold;
 | 
				
			||||||
 | 
					+	/* imod_interval in ns (I * 250ns) */
 | 
				
			||||||
 | 
					+	u32		imod_interval;
 | 
				
			||||||
 | 
					 	int		event_ring_max;
 | 
				
			||||||
 | 
					 	/* 4KB min, 128MB max */
 | 
				
			||||||
 | 
					 	int		page_size;
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					From bbbbdd36c7311a786d7392f2394b355b1f78cf8b Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 3 Jan 2018 16:53:21 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 192/224] dt-bindings: usb: mtk-xhci: update USB wakeup
 | 
				
			||||||
 | 
					 properties
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Add two arguments in "mediatek,syscon-wakeup" to support multi
 | 
				
			||||||
 | 
					wakeup glue layer between SSUSB and SPM, and use standard property
 | 
				
			||||||
 | 
					"wakeup-source" to replace the private "mediatek,wakeup-src"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
 | 
				
			||||||
 | 
					Reviewed-by: Rob Herring <robh@kernel.org>
 | 
				
			||||||
 | 
					Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 .../devicetree/bindings/usb/mediatek,mtk-xhci.txt        | 16 ++++++++++------
 | 
				
			||||||
 | 
					 1 file changed, 10 insertions(+), 6 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					index 9ff560298498..88d9f4a4b280 100644
 | 
				
			||||||
 | 
					--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 | 
				
			||||||
 | 
					@@ -35,10 +35,14 @@ Required properties:
 | 
				
			||||||
 | 
					  - phys : a list of phandle + phy specifier pairs
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 Optional properties:
 | 
				
			||||||
 | 
					- - mediatek,wakeup-src : 1: ip sleep wakeup mode; 2: line state wakeup
 | 
				
			||||||
 | 
					-	mode;
 | 
				
			||||||
 | 
					- - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
 | 
				
			||||||
 | 
					-	control register, it depends on "mediatek,wakeup-src".
 | 
				
			||||||
 | 
					+ - wakeup-source : enable USB remote wakeup;
 | 
				
			||||||
 | 
					+ - mediatek,syscon-wakeup : phandle to syscon used to access the register
 | 
				
			||||||
 | 
					+	of the USB wakeup glue layer between xHCI and SPM; it depends on
 | 
				
			||||||
 | 
					+	"wakeup-source", and has two arguments:
 | 
				
			||||||
 | 
					+	- the first one : register base address of the glue layer in syscon;
 | 
				
			||||||
 | 
					+	- the second one : hardware version of the glue layer
 | 
				
			||||||
 | 
					+		- 1 : used by mt8173 etc
 | 
				
			||||||
 | 
					+		- 2 : used by mt2712 etc
 | 
				
			||||||
 | 
					  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 | 
				
			||||||
 | 
					 	bit1 for u3port1, ... etc;
 | 
				
			||||||
 | 
					  - vbus-supply : reference to the VBUS regulator;
 | 
				
			||||||
 | 
					@@ -65,8 +69,8 @@ usb30: usb@11270000 {
 | 
				
			||||||
 | 
					 	vusb33-supply = <&mt6397_vusb_reg>;
 | 
				
			||||||
 | 
					 	vbus-supply = <&usb_p1_vbus>;
 | 
				
			||||||
 | 
					 	usb3-lpm-capable;
 | 
				
			||||||
 | 
					-	mediatek,syscon-wakeup = <&pericfg>;
 | 
				
			||||||
 | 
					-	mediatek,wakeup-src = <1>;
 | 
				
			||||||
 | 
					+	mediatek,syscon-wakeup = <&pericfg 0x400 1>;
 | 
				
			||||||
 | 
					+	wakeup-source;
 | 
				
			||||||
 | 
					 	imod-interval-ns = <10000>;
 | 
				
			||||||
 | 
					 };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -0,0 +1,77 @@
 | 
				
			|||||||
 | 
					From 0f9391b4ee12cad5c93e109b9eb6c0c6298da0d3 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Fri, 5 Jan 2018 16:14:06 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 193/224] clk: mediatek: adjust dependency of reset.c to avoid
 | 
				
			||||||
 | 
					 unexpectedly being built
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Changes from v1->v2:
 | 
				
			||||||
 | 
					Add 'select RESET_CONTROLLER' under COMMON_CLK_MEDIATEK and enable
 | 
				
			||||||
 | 
					reset.c to be built when COMMON_CLK_MEDIATEK is selected. That should
 | 
				
			||||||
 | 
					be quite reasonable because the reset controller is tightly embedded
 | 
				
			||||||
 | 
					inside and exported from these clock subsystems. At least it can be found
 | 
				
			||||||
 | 
					on infracfg and pericfg subsystem that both are really fundamental block
 | 
				
			||||||
 | 
					lots of devices must depend on.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					commit 74cb0d6dde8 ("clk: mediatek: fixup test-building of MediaTek clock
 | 
				
			||||||
 | 
					drivers") can let the build system looking into the directory where the
 | 
				
			||||||
 | 
					clock drivers resides and then allow test-building the drivers.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					But the change also gives rise to certain incorrect behavior which is
 | 
				
			||||||
 | 
					reset.c being built even not depending on either COMPILE_TEST or
 | 
				
			||||||
 | 
					ARCH_MEDIATEK alternative dependency. To get rid of reset.c being built
 | 
				
			||||||
 | 
					unexpectedly on the other platforms, it would be a good change that the
 | 
				
			||||||
 | 
					file should be built depending on its own specific configuration rather
 | 
				
			||||||
 | 
					than just on generic RESET_CONTROLLER one.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Cc: Jean Delvare <jdelvare@suse.de>
 | 
				
			||||||
 | 
					Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/clk/mediatek/Kconfig   | 1 +
 | 
				
			||||||
 | 
					 drivers/clk/mediatek/Makefile  | 4 ++--
 | 
				
			||||||
 | 
					 drivers/clk/mediatek/clk-mtk.h | 7 -------
 | 
				
			||||||
 | 
					 3 files changed, 3 insertions(+), 9 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Index: linux-4.14.25/drivers/clk/mediatek/Kconfig
 | 
				
			||||||
 | 
					===================================================================
 | 
				
			||||||
 | 
					--- linux-4.14.25.orig/drivers/clk/mediatek/Kconfig
 | 
				
			||||||
 | 
					+++ linux-4.14.25/drivers/clk/mediatek/Kconfig
 | 
				
			||||||
 | 
					@@ -6,6 +6,7 @@ menu "Clock driver for MediaTek SoC"
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 config COMMON_CLK_MEDIATEK
 | 
				
			||||||
 | 
					 	bool
 | 
				
			||||||
 | 
					+	select RESET_CONTROLLER
 | 
				
			||||||
 | 
					 	---help---
 | 
				
			||||||
 | 
					 	  MediaTek SoCs' clock support.
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					Index: linux-4.14.25/drivers/clk/mediatek/Makefile
 | 
				
			||||||
 | 
					===================================================================
 | 
				
			||||||
 | 
					--- linux-4.14.25.orig/drivers/clk/mediatek/Makefile
 | 
				
			||||||
 | 
					+++ linux-4.14.25/drivers/clk/mediatek/Makefile
 | 
				
			||||||
 | 
					@@ -1,6 +1,5 @@
 | 
				
			||||||
 | 
					 # SPDX-License-Identifier: GPL-2.0
 | 
				
			||||||
 | 
					-obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o
 | 
				
			||||||
 | 
					-obj-$(CONFIG_RESET_CONTROLLER) += reset.o
 | 
				
			||||||
 | 
					+obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o reset.o
 | 
				
			||||||
 | 
					 obj-$(CONFIG_COMMON_CLK_MT6797) += clk-mt6797.o
 | 
				
			||||||
 | 
					 obj-$(CONFIG_COMMON_CLK_MT6797_IMGSYS) += clk-mt6797-img.o
 | 
				
			||||||
 | 
					 obj-$(CONFIG_COMMON_CLK_MT6797_MMSYS) += clk-mt6797-mm.o
 | 
				
			||||||
 | 
					Index: linux-4.14.25/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					===================================================================
 | 
				
			||||||
 | 
					--- linux-4.14.25.orig/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					+++ linux-4.14.25/drivers/clk/mediatek/clk-mtk.h
 | 
				
			||||||
 | 
					@@ -229,14 +229,7 @@ void mtk_clk_register_plls(struct device
 | 
				
			||||||
 | 
					 struct clk *mtk_clk_register_ref2usb_tx(const char *name,
 | 
				
			||||||
 | 
					 			const char *parent_name, void __iomem *reg);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-#ifdef CONFIG_RESET_CONTROLLER
 | 
				
			||||||
 | 
					 void mtk_register_reset_controller(struct device_node *np,
 | 
				
			||||||
 | 
					 			unsigned int num_regs, int regofs);
 | 
				
			||||||
 | 
					-#else
 | 
				
			||||||
 | 
					-static inline void mtk_register_reset_controller(struct device_node *np,
 | 
				
			||||||
 | 
					-			unsigned int num_regs, int regofs)
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-}
 | 
				
			||||||
 | 
					-#endif
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 #endif /* __DRV_CLK_MTK_H */
 | 
				
			||||||
@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					From cfcb2cc358f3ff466d4c419d8f6fe0263bdc47b1 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Date: Wed, 10 Jan 2018 00:28:24 +0800
 | 
				
			||||||
 | 
					Subject: [PATCH 194/224] pinctrl: mediatek: mt7622: fix potential
 | 
				
			||||||
 | 
					 uninitialized value being returned
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					commit d6ed93551320 ("pinctrl: mediatek: add pinctrl driver for MT7622
 | 
				
			||||||
 | 
					SoC") leads to the following static checker warning:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					drivers/pinctrl/mediatek/pinctrl-mt7622.c:1419 mtk_gpio_get()
 | 
				
			||||||
 | 
					error: uninitialized symbol 'value'.
 | 
				
			||||||
 | 
					1412  static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
 | 
				
			||||||
 | 
					1413  {
 | 
				
			||||||
 | 
					1414          struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
 | 
				
			||||||
 | 
					1415          int value;
 | 
				
			||||||
 | 
					1416
 | 
				
			||||||
 | 
					1417          mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
 | 
				
			||||||
 | 
					^^^^^^^^^^^^^^^^
 | 
				
			||||||
 | 
					1418
 | 
				
			||||||
 | 
					1419          return !!value;
 | 
				
			||||||
 | 
					1420  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The appropriate error handling must be added to avoid the potential error
 | 
				
			||||||
 | 
					caused by uninitialized value being returned.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
 | 
				
			||||||
 | 
					Signed-off-by: Sean Wang <sean.wang@mediatek.com>
 | 
				
			||||||
 | 
					Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
 | 
				
			||||||
 | 
					Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					 drivers/pinctrl/mediatek/pinctrl-mt7622.c | 6 ++++--
 | 
				
			||||||
 | 
					 1 file changed, 4 insertions(+), 2 deletions(-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
 | 
				
			||||||
 | 
					index 3824d82888ac..dc32e3c3bd73 100644
 | 
				
			||||||
 | 
					--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
 | 
				
			||||||
 | 
					+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
 | 
				
			||||||
 | 
					@@ -1412,9 +1412,11 @@ static struct pinctrl_desc mtk_desc = {
 | 
				
			||||||
 | 
					 static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					 	struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
 | 
				
			||||||
 | 
					-	int value;
 | 
				
			||||||
 | 
					+	int value, err;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-	mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
 | 
				
			||||||
 | 
					+	err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
 | 
				
			||||||
 | 
					+	if (err)
 | 
				
			||||||
 | 
					+		return err;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 	return !!value;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					-- 
 | 
				
			||||||
 | 
					2.11.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue
	
	Block a user